Skip to content

Library Manager commands can produce redundant installations #1870

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
per1234 opened this issue Sep 9, 2022 · 1 comment
Closed
3 tasks done

Library Manager commands can produce redundant installations #1870

per1234 opened this issue Sep 9, 2022 · 1 comment
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Sep 9, 2022

Describe the problem

Libraries are identified by the "real name" defined in the name field of the library.properties metadata file (or by the folder name in the case of a "legacy"/"1.0 format" library that doesn't have a metadata file).

During the implementation of the Arduino Library Manager system, an unfortunate decision was made to reuse the user's library folder (<directories.data/libraries or LIBRARY_LOCATION_USER). This can be problematic because the set of libraries recognized by Library Manager include those installed by the user via alternative methods:

Libraries installed via arduino-cli lib install are always installed to a folder named by "sanitizing" the "real name". However, installations of a library made via other methods can have any arbitrary folder name.

🐛 If a library was installed to a folder with a name different from the sanitized "real name", the Library Manager commands that install a library generate a separate installation of the library. This means that multiple libraries with the same identifier are installed in LIBRARY_LOCATION_USER, which breaks some of the Library Manager capabilities.

To reproduce

lib install demo

$ arduino-cli version
arduino-cli.exe  Version: git-snapshot Commit: 3cd782d6 Date: 2022-09-07T19:10:31Z

$ export ARDUINO_DIRECTORIES_USER="/tmp/arduino-cli-directories/user"

$ export ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL="true"

$ arduino-cli lib install --git-url https://github.com/arduino-libraries/SigFox
--git-url and --zip-path flags allow installing untrusted files, use it at your own risk.
Enumerating objects: 86, done.
Counting objects: 100% (86/86), done.
Compressing objects: 100% (62/62), done.
Total 86 (delta 30), reused 64 (delta 20), pack-reused 0
Library installed

$ ls "$ARDUINO_DIRECTORIES_USER/libraries"
SigFox/

$ arduino-cli lib list
Name                          Installed     Available         Location              Description
Arduino SigFox for MKRFox1200 1.0.5         -                 LIBRARY_LOCATION_USER -

$ arduino-cli lib install "Arduino SigFox for MKRFox1200"
Downloading Arduino SigFox for [email protected]...
Arduino SigFox for [email protected] already downloaded
Installing Arduino SigFox for [email protected]...
Installed Arduino SigFox for [email protected]

$ ls "$ARDUINO_DIRECTORIES_USER/libraries"
Arduino_SigFox_for_MKRFox1200/  SigFox/

$ arduino-cli lib list
Name                          Installed Available    Location              Description     
Arduino SigFox for MKRFox1200 1.0.4     -            LIBRARY_LOCATION_USER -
 "                            1.0.5     -            LIBRARY_LOCATION_USER -

🐛 There are now two "Arduino SigFox for MKRFox1200" libraries installed in LIBRARY_LOCATION_USER. It is impossible for some Library Manager commands to operate correctly under these conditions.

lib upgrade demo

$ arduino-cli version
arduino-cli.exe  Version: git-snapshot Commit: 3cd782d6 Date: 2022-09-07T19:10:31Z

$ export ARDUINO_DIRECTORIES_USER="/tmp/arduino-cli-directories/user"

$ export ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL="true"

$ arduino-cli lib install --git-url https://github.com/arduino-libraries/SigFox#1.0.3  # install outdated version of library
--git-url and --zip-path flags allow installing untrusted files, use it at your own risk.
Enumerating objects: 86, done.
Counting objects: 100% (86/86), done.
Compressing objects: 100% (62/62), done.
Total 86 (delta 30), reused 64 (delta 20), pack-reused 0
Library installed

$ ls "$ARDUINO_DIRECTORIES_USER/libraries"
SigFox/

$ arduino-cli lib list
Name                          Installed     Available         Location              Description
Arduino SigFox for MKRFox1200 1.0.5         -                 LIBRARY_LOCATION_USER -

$ arduino-cli lib upgrade "Arduino SigFox for MKRFox1200"
Downloading Arduino SigFox for [email protected]...
Arduino SigFox for [email protected] already downloaded
Installing Arduino SigFox for [email protected]...
Installed Arduino SigFox for [email protected]

$ ls "$ARDUINO_DIRECTORIES_USER/libraries"
Arduino_SigFox_for_MKRFox1200/  SigFox/

$ arduino-cli lib list
Name                          Installed Available      Location              Description
Arduino SigFox for MKRFox1200 1.0.4     -              LIBRARY_LOCATION_USER -
 "                            1.0.3     1.0.4          LIBRARY_LOCATION_USER Helper library for MKRFox1200 board a...

🐛 There are now two "Arduino SigFox for MKRFox1200" libraries installed in LIBRARY_LOCATION_USER. It is impossible for some Library Manager commands to operate correctly under these conditions.

Expected behavior

arduino-cli lib commands must never result in multiple libraries with the same identifier being installed in LIBRARY_LOCATION_USER.

They should use one of the following approaches:

Remove previous installation after installing to a new folder name.

OR

Update in place, using the folder name of the existing library.

Arduino CLI version

3cd782d

Operating system

Windows, Ubuntu

Operating system version

Windows 10, Ubuntu 20.04

Additional context

This produces the conditions for #1871

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
@cmaglie
Copy link
Member

cmaglie commented Sep 22, 2022

Fixed by #1878

@cmaglie cmaglie closed this as completed Sep 22, 2022
@per1234 per1234 added the conclusion: resolved Issue was resolved label Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

2 participants