arduino / arduino-cli

Arduino command line tool
https://arduino.github.io/arduino-cli/latest/
GNU General Public License v3.0
4.36k stars 384 forks source link

`lib list` and `lib examples` use incorrect library name #1577

Closed per1234 closed 2 years ago

per1234 commented 2 years ago

Bug Report

The name of an Arduino library is defined by the name property of its library.properties metadata file.

This is the sole unique identifier for the library, which is used in the LIBRARY_NAME argument of the arduino-cli lib commands. However, two of the commands instead use the library's folder name for the library name instead of its real name.

Current behavior

The following demonstration uses the "Arduino SigFox for MKRFox1200" library, the name of which is defined here: https://github.com/arduino-libraries/SigFox/blob/1.0.4/library.properties#L1

name=Arduino SigFox for MKRFox1200

This library was selected because the spaces in the name cause the "normalized" Library Manager installation folder name (Arduino_SigFox_for_MKRFox1200) to be different from the library name.

$ arduino-cli version
arduino-cli.exe  Version: nightly-20211201 Commit: 55ad9ec Date: 2021-12-01T01:29:21Z

$ arduino-cli lib search "Arduino_SigFox_for_MKRFox1200"
Updating index: library_index.json.gz downloaded ?  19988.48% 00m02s1s
Updating index: library_index.json.sig downloaded
No libraries matching your search.

$ arduino-cli lib search "Arduino SigFox for MKRFox1200"
Updating index: library_index.json.gz downloaded ?  19988.48% 00m02s1s
Updating index: library_index.json.sig downloaded
Name: "Arduino SigFox for MKRFox1200"
  Author: Arduino
  Maintainer: Arduino LLC
  Sentence: Helper library for MKRFox1200 board and ATAB8520E Sigfox module
  Paragraph: This library allows some high level operations on Sigfox module, to ease integration with existing projects
  Website: https://www.arduino.cc/en/Reference/SigFox
  Category: Device Control
  Architecture: samd
  Types: Arduino
  Versions: [1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4]

$ arduino-cli lib download "Arduino_SigFox_for_MKRFox1200"
Error downloading Arduino_SigFox_for_MKRFox1200: Library 'Arduino_SigFox_for_MKRFox1200' not found

$ arduino-cli lib download "Arduino SigFox for MKRFox1200"
Arduino SigFox for MKRFox1200@1.0.4 downloaded

$ arduino-cli lib install "Arduino_SigFox_for_MKRFox1200"
Error installing Arduino_SigFox_for_MKRFox1200: Library 'Arduino_SigFox_for_MKRFox1200' not found

$ arduino-cli lib install "Arduino SigFox for MKRFox1200"
Downloading Arduino SigFox for MKRFox1200@1.0.4...
Arduino SigFox for MKRFox1200@1.0.4 already downloaded
Installing Arduino SigFox for MKRFox1200@1.0.4...
Installed Arduino SigFox for MKRFox1200@1.0.4

$ arduino-cli lib deps "Arduino_SigFox_for_MKRFox1200"
Error resolving dependencies for Arduino_SigFox_for_MKRFox1200: Library 'Arduino_SigFox_for_MKRFox1200' not found

$ arduino-cli lib deps "Arduino SigFox for MKRFox1200"
✕ Arduino SigFox for MKRFox1200 1.0.4 must be installed.

$ arduino-cli lib list "Arduino_SigFox_for_MKRFox1200"
Name                          Installed     Available         Location              Description
Arduino_SigFox_for_MKRFox1200 1.0.4         -                 LIBRARY_LOCATION_USER -

$ arduino-cli lib list "Arduino SigFox for MKRFox1200"
No libraries installed.

$ arduino-cli lib examples "Arduino_SigFox_for_MKRFox1200"
Examples for library Arduino_SigFox_for_MKRFox1200
  - C:\Users\per\Documents\Arduino\libraries\Arduino_SigFox_for_MKRFox1200\examples\EventTrigger
  - C:\Users\per\Documents\Arduino\libraries\Arduino_SigFox_for_MKRFox1200\examples\FirstConfiguration
  - C:\Users\per\Documents\Arduino\libraries\Arduino_SigFox_for_MKRFox1200\examples\SendBoolean
  - C:\Users\per\Documents\Arduino\libraries\Arduino_SigFox_for_MKRFox1200\examples\WeatherMonitor
  - C:\Users\per\Documents\Arduino\libraries\Arduino_SigFox_for_MKRFox1200\examples\WeatherMonitorStream

$ arduino-cli lib examples "Arduino SigFox for MKRFox1200"
No libraries found.

Notice that in all cases except lib list and lib examples, the library name is "Arduino SigFox for MKRFox1200", while that correct name is not recognized when used in the library name argument of the final two commands.

Expected behavior

Libraries are always referred to by the correct name, consistently from one command to another.

Environment

Additional context

There is one case where the library folder name determines the library name: the "1.0 format" or "legacy" libraries that do not have a library.properties metadata file:

https://arduino.github.io/arduino-cli/dev/library-specification/#old-library-format-pre-15


The name field value is sometimes referred to as the "real name" or "fancy name".

per1234 commented 2 years ago

Closing as duplicate of https://github.com/arduino/arduino-cli/issues/932