Skip to content

lib examples does not respect bundled versus installed libraries priority #1656

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

Closed
3 tasks done
JAndrassy opened this issue Jan 5, 2022 · 1 comment · Fixed by #2113
Closed
3 tasks done

lib examples does not respect bundled versus installed libraries priority #1656

JAndrassy opened this issue Jan 5, 2022 · 1 comment · Fixed by #2113
Assignees
Labels
criticality: medium Of moderate impact topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@JAndrassy
Copy link

JAndrassy commented Jan 5, 2022

Describe the problem

In Examples menu a multi-platform library examples are shown instated of bundled library with the same name.

My ArduinoOTA library examples are in Examples menu even when ESP8266 board is selected. The ESP8266 platform has a bundled ArduinoOTA library.

Operating system

Linux Mint

Additional context

Examples respect library priority in Arduino IDE 1.x.


Additional reports:

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details
@ghost ghost assigned silvanocerza Jan 5, 2022
@per1234 per1234 transferred this issue from arduino/arduino-ide Feb 7, 2022
@per1234
Copy link
Contributor

per1234 commented Feb 7, 2022

I transferred this issue to the Arduino CLI repository because it seems the bug is in this code base:

$ arduino-cli version
arduino-cli.exe  Version: nightly-20220207 Commit: 10107d2 Date: 2022-02-07T01:28:33Z

$ arduino-cli core update-index --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json
Updating index: package_index.json downloaded / 439.91 KiB   23.64% 00m01s
Updating index: package_index.json.sig downloaded
Updating index: package_esp8266com_index.json downloaded85 KiB    0.00%

$ arduino-cli core install --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json esp8266:[email protected]
Downloading packages...
esp8266:[email protected] already downloaded
esp8266:[email protected] already downloaded
esp8266:[email protected] already downloaded
esp8266:[email protected] already downloaded
esp8266:[email protected] already downloaded
Installing esp8266:[email protected]...
esp8266:[email protected] installed
Installing esp8266:[email protected]...
esp8266:[email protected] installed
Installing esp8266:[email protected]...
esp8266:[email protected] installed
Installing esp8266:[email protected]...
esp8266:[email protected] installed
Installing platform esp8266:[email protected]...
Configuring platform....
Platform esp8266:[email protected] installed

$ arduino-cli lib install [email protected]
Downloading [email protected]...
[email protected] downloaded/ 69.86 KiB   68.71%
Installing [email protected]...
Installed [email protected]

$ arduino-cli lib examples --fqbn esp8266:esp8266:generic
Examples for library ArduinoOTA
  - C:\Users\per\Documents\Arduino\libraries\ArduinoOTA\examples\Advanced\OTASketchDownload
  - C:\Users\per\Documents\Arduino\libraries\ArduinoOTA\examples\Advanced\OTASketchDownload_SD
  - C:\Users\per\Documents\Arduino\libraries\ArduinoOTA\examples\Advanced\OTASketchDownloadWifi
  - C:\Users\per\Documents\Arduino\libraries\ArduinoOTA\examples\ATmega_SD
  - C:\Users\per\Documents\Arduino\libraries\ArduinoOTA\examples\OTEthernet
  - C:\Users\per\Documents\Arduino\libraries\ArduinoOTA\examples\OTEthernet_SD
  - C:\Users\per\Documents\Arduino\libraries\ArduinoOTA\examples\SerialWiFiOTA
  - C:\Users\per\Documents\Arduino\libraries\ArduinoOTA\examples\WiFi101_OTA
  - C:\Users\per\Documents\Arduino\libraries\ArduinoOTA\examples\WiFi101_SD_OTA

But this is not the library that is used when compiling for that board:

$ mkdir -p /tmp/ArduinoOTATest

$ echo "#include <ArduinoOTA.h>
> void setup() {}
> void loop() {}" > /tmp/ArduinoOTATest/ArduinoOTATest.ino

$ arduino-cli compile --fqbn esp8266:esp8266:generic -v /tmp/ArduinoOTATest

[...]

Multiple libraries were found for "ArduinoOTA.h"
  Used: C:\Users\per\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ArduinoOTA
  Not used: C:\Users\per\Documents\Arduino\libraries\ArduinoOTA

The esp8266 platform bundled library is "architecture optimized" for the esp8266 architecture of the esp8266:esp8266:generic:

https://github.com/esp8266/Arduino/blob/3.0.2/libraries/ArduinoOTA/library.properties#L9

architectures=esp8266

This causes it to be given priority by the library dependency resolution system over the sketchbook installed "ArduinoOTA" library, which is only "architecture compatible":

https://github.com/jandrassy/ArduinoOTA/blob/1.0.7/library.properties#L9

architectures=*

As mentioned by jandrassy, Arduino IDE 2.x incorrectly shows the sketchbook installed "ArduinoOTA" library examples in the File > Examples menu, while Arduino IDE 1.8.19 and older correctly show the examples associated with the library that has architecture priority for the currently selected board:

  • Boards of the esp8266:esp8266 platform - the examples of the platform bundled "ArduinoOTA" library:
    image
  • Boards of any other platform - The examples of the sketchbook installed "ArduinoOTA" library:
    image

@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Feb 7, 2022
@per1234 per1234 changed the title Examples menu - bundled versus installed libraries priority lib examples does not respect bundled versus installed libraries priority Feb 7, 2022
@per1234 per1234 assigned cmaglie and unassigned silvanocerza Apr 4, 2022
@ubidefeo ubidefeo added the criticality: medium Of moderate impact label Jul 25, 2022
@umbynos umbynos added this to the Arduino CLI 1.0 milestone Feb 2, 2023
@umbynos umbynos assigned Bikappa and unassigned cmaglie Mar 6, 2023
@cmaglie cmaglie assigned cmaglie and unassigned Bikappa Mar 17, 2023
cmaglie added a commit to cmaglie/arduino-cli that referenced this issue Mar 20, 2023
cmaglie added a commit to cmaglie/arduino-cli that referenced this issue Mar 20, 2023
cmaglie added a commit to cmaglie/arduino-cli that referenced this issue Mar 22, 2023
cmaglie added a commit that referenced this issue Mar 22, 2023
…ow platform bundled lib when lib of same name is installed globally (#2113)

* Added test

* Factored function to determine library compatibility

* Made ComputePriority function public

* fix: use the libraries resolution algorithm to determine library priority

* Slightly refactored 'lib list' command call

* Updated UPGRADING.md

* Added test for a similar bug in `lib examples`

See #1656
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
criticality: medium Of moderate impact topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
7 participants