Arduino icon indicating copy to clipboard operation
Arduino copied to clipboard

Add the ability to find libraries in sketch folder.

Open Steve132 opened this issue 4 years ago • 6 comments

Feature Explaination:

This is a patch to allow the user to search sketches by default in the <Sketch>/libraries folder if it exists. This feature is referenced and/or requested here:

https://github.com/arduino/arduino-builder/pull/223 https://github.com/arduino/Arduino/issues/4936 https://github.com/arduino/Arduino/issues/4936#issuecomment-436803575 https://github.com/arduino/Arduino/issues/9507 https://github.com/arduino/Arduino/issues/7755 https://github.com/arduino/Arduino/issues/11106

This adds this feature to the Arduino IDE provided that the user has enabled it in their preferences. This preference is disabled by default in order to avoid breaking past behavior by default (in the exceedingly unlikely case that the user had a libraries directory in their sketch that they did NOT wish to be compiled).

This feature is not needed to be implemented in arduino-cli, because the user of arduino-cli could always manually add "--libraries pwd" or similar very easily in their command line build. However, it may be a good idea to add by default as a potential future feature.

All Submissions:

  • [X] Have you followed the guidelines in our Contributing document?
  • [X] Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. [X] Does your submission pass tests?
  2. [X] Have you lint your code locally prior to submission?

Steve132 avatar Dec 28 '20 22:12 Steve132

Going even further, I wonder if we need a visible preference for this at all? If this is just enabled by default, having a preference in preferences.txt (but not shown in the GUI) to disable it just in case could be fine.

I honestly tend to agree, but since this is my first contribution to Arduino I thought it might be better to avoid any breaking changes and to make sure I dotted my i's and crossed my t's with regards to possibly making breaking changes.

I would really want to see this in arduino-cli as well (also enabled by default IMHO), since then a single sketch will end up behaving the same between -cli and the IDE. I suspect that this is similarly easy to implement in arduino-cli, though.

This is true. I didn't do this yet, but I can if this patch gets merged. I don't want to make the change to arduino-cli until then.

Did you check what the priority of this extra libraries directory will be? IIRC arduino-builder has some code to apply different priorities to different library folders (In particular the platform-specific libraries are treated specially, probably using the order specified on the commandline for other libraries?).

I saw that, but the only way I mitigated it is to make sure this comes first.

Steve132 avatar Dec 29 '20 15:12 Steve132

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 09 '21 12:04 CLAassistant

I really would love this feature to be added.

jwktje avatar Aug 04 '21 10:08 jwktje

Why is this still not added??!? It is such a basic function of wanting to modify a library because it is missing a function or because you are working in a team and want to ensure your sketch shares the same library.

Stefanhg avatar May 14 '22 15:05 Stefanhg

Hi, what's the status of this PR?

Levi-Lesches avatar Mar 20 '23 19:03 Levi-Lesches

This is a simple, basic and completely obvious feature, that I for one think should be enabled by default. It needs to be implemented yesterday. Not having this has been a huge problem for so long I can't even remember when I first ran into it and wondered how it had been missed. The src/ workaround does not work when libraries reference other libraries.

stg avatar Dec 06 '23 10:12 stg