-
-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Library Name Priority" feature impacts some platform bundled libraries #1292
Comments
For those who are not fully familiar with the history of the library selection priority management,
Where
-name=SD(esp32)
+name=SD Please feel free to reformulate my question if I did not get it right :) |
Hi @d-a-v. I believe this is the full summary:
Please let me know if anything is unclear. |
Then for previous (and current) platform release up to now,
Thanks this is now very clear @per1234 ! My next question would be whether it is fair/easy/possible to add some kind of warning in Arduino IDE 1.8.16+ (or matching Arduino CLI) that would inform the user that a deprecated workaround is used in some library specification, that would potentially lead to incompatibilities ? Such message would be, I think, valuable in bug reports. |
I agree. This was part of the motivation behind temporarily reverting the change and immediately making new releases without the change once the scope of the impact became clear. This time around, we are making extra effort to give affected projects time to prepare for the change, providing clear documentation and communication about it to make sure everyone is aware in advance.
Well, in some ways this is already done via the "Multiple libraries were found for ..." message shown by all Arduino development software in this situation. For example:
The tricky thing is that library overrides are a normal occurrence and a very useful feature. The boards platforms use it to provide their own board's versions of the standalone libraries. Library Manager uses it to provide updates for the IDE's pre-installed "built-in" libraries. The users may use it to override stock libraries with customized versions. So you can't treat an occurrence of an override as an error, nor even a warning. In fact, I regularly see the "Multiple libraries were found for ..." informational message cause undue alarm to users who think it indicates a problem when in reality it is a case where everything is working just as intended and the correct library was selected. I suppose an additional message could be added for when "Library Name Priority" resulted in a priority inversion when compared to how it would have been prior to the introduction of this new priority determination factor. But you can't treat that as a warning because this new factor was introduced specifically to deal with other cases where the previous priority factors resulted in the wrong library being selected. So a different priority result after this change is not necessarily a bad thing (otherwise there would be no point in it). I definitely am interested in hearing any ideas others have on the subject. |
To make the future incompatibility crystal clear, I still have some interrogations. -name=SD(esp32)
+name=SD I guess it won't work because the name |
It won't work because, when using the library's primary header file name in an The old priority system is documented here: Comparison of priority scores for
Platform bundled library wins because it is "Architecture optimized" (e.g., The new priority system is documented here: Comparison of priority scores for
The standalone library wins because, due to its
It is currently "sanitized" to However, note that the previous use of the parentheses characters in the library name technically makes it in violation of the Arduino Library Specification:
This specification is not currently enforced on platform bundled libraries, but it's definitely a good idea to always follow the specification, as there is no guarantee of support for non-compliance. I'm actually to blame for the choice to use parentheses in the library name when modifying the library names as a workaround for arduino/Arduino#4189 back in the 2015 era. At that time, we didn't have any specification as to the library name requirements. I certainly cringed later when I realized I had done this while establishing that documentation. But the poorly chosen characters has not done any harm so far. Although the workaround itself has now become problematic, the specification violation introduced coincidentally via the workaround is not relevant to the current situation. There are still some remaining platform bundled libraries with the non-compliant names (Servo being the one I noticed), but those were not affected by the "Library Name Priority" change, so I considered changing those names to be out of scope for the PRs I submitted for mitigating the harmful impact of "Library Name Priority".
I should make clear that there is no magic specific to the |
I'll provide an update on this: the "Library Name Priority" feature was reintroduced in the following Arduino software versions At the time I write this, it has not yet been reintroduced into arduino-builder or the classic Arduino IDE. They are still using (reference: builder, IDE) Arduino CLI 0.18.3, the last release before the reintroduction of "Library Name Priority". |
Since it has now been 6 months since the release of the change, the problematic library metadata has been corrected in all known affected platforms, and no significant recent reports of impacts, I think the need to leave this open for maximum visibility has passed. |
#1276 added a nice new "Library Name Priority" feature where the library dependency system uses the similarity of the library
name
value and the filename of an#include
directive as one of the factors in deciding which library to use when multiple matching matching libraries are installed. This was released with Arduino CLI 0.18.2 (and the Arduino IDE 1.8.14 and 2.0.0-beta.6 releases which use it).Unfortunately, this change resulted in some platform bundled libraries which had previously been correctly correctly chosen no longer being given priority over the general purpose libraries from Arduino Library Manager.
An example:
You can see that the
esp32:esp32
platform's bundled library, which is written specifically for ESP32 architecture, was not chosen, contrary to the expected behavior. The reason can be seen in the library'slibrary.properties
metadata file here:https://github.com/espressif/arduino-esp32/blob/1.0.6/libraries/SD/library.properties#L1
While the general purpose library's metadata is a perfect match for the
SD.h
file of the#include
directive:https://github.com/arduino-libraries/SD/blob/1.2.4/library.properties#L1
The reason the names of some platform bundled libraries have these suffixes is to workaround a bug which caused libraries to be considered perpetually updatable by the the Arduino IDE's Library Manager when they had the same name as the platform bundled library:
arduino/Arduino#4189
This bug was fixed in Arduino IDE 1.8.6, ~3 years ago, but there was never a reason for the platform authors to change them back to their proper values.
Once this unexpected state of affairs was revealed, it was decided that the best approach would be to revert the change (#1290) and make a 0.18.3 release of Arduino CLI (accompanied by Arduino IDE 1.8.15 and 2.0.0-beta.7) in order to allow time for the maintainers of affected projects to prepare. The "Library Name Priority" feature will be added back in the next release of Arduino CLI and the IDEs. In order to ensure platform bundled libraries get the correct priority, the only necessary change is simply to change the library.properties
name
values to match the primary header file after any spaces have been replaced by_
:Standalone libraries should not be affected by this feature because the Library Manager installation folder name is determined by the
name
value, and thus their dependency resolution priority was already dependent on the name.The text was updated successfully, but these errors were encountered: