Skip to content

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

Closed
@JAndrassy

Description

@JAndrassy

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
    I verified the problem still occurs when using the
    My report contains all necessary details

Activity

transferred this issue fromarduino/arduino-ideon Feb 7, 2022
per1234

per1234 commented on Feb 7, 2022

@per1234
Contributor

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:esp8266@3.0.2
Downloading packages...
esp8266:xtensa-lx106-elf-gcc@3.0.4-gcc10.3-1757bed already downloaded
esp8266:mkspiffs@3.0.4-gcc10.3-1757bed already downloaded
esp8266:mklittlefs@3.0.4-gcc10.3-1757bed already downloaded
esp8266:python3@3.7.2-post1 already downloaded
esp8266:esp8266@3.0.2 already downloaded
Installing esp8266:xtensa-lx106-elf-gcc@3.0.4-gcc10.3-1757bed...
esp8266:xtensa-lx106-elf-gcc@3.0.4-gcc10.3-1757bed installed
Installing esp8266:mkspiffs@3.0.4-gcc10.3-1757bed...
esp8266:mkspiffs@3.0.4-gcc10.3-1757bed installed
Installing esp8266:mklittlefs@3.0.4-gcc10.3-1757bed...
esp8266:mklittlefs@3.0.4-gcc10.3-1757bed installed
Installing esp8266:python3@3.7.2-post1...
esp8266:python3@3.7.2-post1 installed
Installing platform esp8266:esp8266@3.0.2...
Configuring platform....
Platform esp8266:esp8266@3.0.2 installed

$ arduino-cli lib install ArduinoOTA@1.0.7
Downloading ArduinoOTA@1.0.7...
ArduinoOTA@1.0.7 downloaded/ 69.86 KiB   68.71%
Installing ArduinoOTA@1.0.7...
Installed ArduinoOTA@1.0.7

$ 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
added
topic: codeRelated to content of the project itself
type: imperfectionPerceived defect in any part of project
on Feb 7, 2022
changed the title [-]Examples menu - bundled versus installed libraries priority[/-] [+]`lib examples` does not respect bundled versus installed libraries priority[/+] on Feb 7, 2022
added this to the Arduino CLI 1.0 milestone on Feb 2, 2023
assigned and unassigned on Mar 6, 2023
assigned and unassigned on Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
`lib examples` does not respect bundled versus installed libraries priority · Issue #1656 · arduino/arduino-cli