arduino / arduino-ide

Arduino IDE 2.x
https://www.arduino.cc/en/software
GNU Affero General Public License v3.0
2.07k stars 353 forks source link

Version management features missing for installed libraries with non-semver versioning #2385

Open per1234 opened 2 months ago

per1234 commented 2 months ago

Describe the problem

Although compliance with the SemVer specification when versioning library releases is recommended to library maintainers, it is not mandatory. Arduino allows an version number that is compliant with what is referred to as "relaxed SemVer". This means that a library might have a version number with a form like 1.2 or even 1.

🐛 If a library is installed that has a non-SemVer version number, some of Library Manager's version management features are not available for that library:

To reproduce

  1. Use Library Manager to install version 1.61.0 of the "AccelStepper" library. Note that after installing, the library entry shows the installed version number is "1.61". 🐛 The version selector menu disappears from the "AccelStepper" library entry. 🐛 There is no "UPDATE" button on the the "AccelStepper" library entry, even though a newer version of the library is available. image
  2. Hover the mouse pointer over the "AccelStepper" entry.
  3. You will see a ●●● icon appear near the top right corner of the library entry. Click on that icon. 🐛 There is no "Remove" item in the menu, even though the library is installed. image
  4. Select "Other Versions" from the menu. A sub-menu will open.
  5. Select "1.59.0" from the menu. 🐛 Version 1.59.0 of the library is not installed.

Expected behavior

Version management features are always available.

Arduino IDE version

aa9b10d

Operating system

Windows

Operating system version

11

Additional context

When a library release is added to the (Library Manager index](http://downloads.arduino.cc/libraries/library_index.json), the version number is converted to the SemVer equivalent (e.g., 1.2 -> 1.2.0). This means that the version numbers in the cc.arduino.cli.commands.v1.LibrarySearch response (which is based on the data from the index) are in SemVer format even when the library's actual version number is not.

Conversely, the version numbers in the cc.arduino.cli.commands.v1.LibraryList response (which is based on the installed library metadata) are in whatever format used by the library maintainer (https://github.com/arduino/arduino-cli/issues/1727).

This means that there is a mismatch between the version numbers from the two responses (both of which are used by the Arduino IDE Library Manager) under these conditions. I suspect the bug is related to this mismatch.

Workaround

Install different version of library
  1. Hover the mouse pointer over the "\<version number> installed" label on the library's Library Manager entry. The label will change to "REMOVE".
  2. Click on "REMOVE". The "Uninstall" dialog will open.
  3. Click the "YES" button in the dialog.
  4. Wait for the uninstall process to finish. A version selector menu will now appear on the library's Library Manager entry.
  5. Select the version you want to install from the version selector menu.
  6. Click the "INSTALL" button.
Update library

Use the "Installing different version" procedure described above to install the latest version of the library.

Uninstall library
  1. Hover the mouse pointer over the "\<version number> installed" label on the library's Library Manager entry. The label will change to "REMOVE".
  2. Click on "REMOVE". The "Uninstall" dialog will open.
  3. Click the "YES" button in the dialog.
  4. Wait for the uninstall process to finish.

Issue checklist