IDE 2.3.6 error installing Keyboard.h library

I mainly use IDE 1.8.19 (largely because of familiarity). Today after many hours trouble-shooting an elusive issue in vain I tried IDE v2 (Surprisingly, whatever version I've used occasionally was no longer present so I installed 2.3.6.)

After opening it I accepted an invitation to update the Keyboard library, but that failed with the message:

Failed to install library: 'Keyboard:1.0.6'. INVALID_ARGUMENT: The library Keyboard has multiple installations: - C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\libraries\Keyboard - C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\libraries\Keyboard_Serial Automatic library install can't be performed in this case, please manually remove all duplicates and retry.

But on returning to IDE 1.8.19 I see that there are no libraries awaiting update. In particular Keyboard 1.0.6 is already installed. I proceeded to establish that my nano upload issue was unchanged (may end up posting about it), but I'm puzzled to know what caused the library problem?

It sounds like you may have two different configurations. If you want to investigate, show us the Sketchbook location in both Arduino IDE 1.x and Arduino IDE 2.x

Identical in both:

C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\

The libraries are the same for both IDE, there is only one sketch folder and one libraries folder. I just installed it in IDE2
Check the IDE2 Library Manager like this


Do you see 1.0.6 installed?

Now I did a search for Keyboard in IDE1.x Library Manager and see identical.

That is how it's supposed to work.

I just noticed your error message has a clue. Fix this first (delete/remove)

Hi @Terrypin.

The identifier for the Arduino library is the value of the name property in the library's library.properties metadata file. This means that it is possible for multiple global library installations to have the same identifier. This isn't something that can happen when you install libraries via Arduino IDE 2.x because it always installs the library under a folder named after the library name, so it is an unusual condition, but it is possible to accomplish it either through a manual library installation, or through the Arduino IDE 1.x "Add .ZIP Library..." feature (which uses the folder name from the ZIP file for the installation).

Arduino IDE isn't smart enough to understand how it should update the library under these conditions, so it errors out and displays this message instructing the user to resolve the library duplication (reference).

If you open the file at this path in a text editor:

C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\libraries\Keyboard_Serial\library.properties

you will see this line in the file:

name=Keyboard

You will of course also see the same in this file:

C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\libraries\Keyboard\library.properties

You will notice that in at least one of those files, the value of the version property is something lower than 1.0.6, which is what causes Arduino IDE to identify the library as updatable.


If these are two redundant copies of the same library, you can resolve the problem by deleting one of the library folders. In this case I would recommend deleting the one with the non-standard folder name:

C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\libraries\Keyboard_Serial

If they are two different libraries, then it is not appropriate for both of them to have the same name. You should change the value of the name property in this file to something unique:

C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\libraries\Keyboard_Serial\library.properties

Although in general the underlying behavior of Arduino IDE 1.x and 2.x are aligned, a large amount of evolution of the codebase has occurred in the years since development on Arduino IDE 1.x ceased. So it is expected that you might observe differences in behavior in obscure corner cases like the one you produced by making multiple global library installations that have the same identifier.

I'm not interested enough in the subject in regards to Arduino IDE 1.x to perform an in depth investigation, but I would guess that the reason it does not consider the library to be updatable is because it considers there to only be a single installation of the library under these conditions, and (whether by accident or design) it uses the version value from the copy that has a version property value of 1.0.6.

No, IDE 2.3.6 had 1.0.4 installed. I was invited to update to 1.0.6, and the failure of that prompted my post.

But your 'clue' later was a good one, well spotted! Examining \libraries I see this:

name=Keyboard  <------------**But this library name is 'Keyboard_Serial'.**
version=1.0.4
author=Arduino
maintainer=Arduino <info@arduino.cc>
sentence=Allows an Arduino board with USB capabilities to act as a Keyboard.
paragraph=This library plugs on the HID library. It can be used with or without other HID-based libraries (Mouse, Gamepad etc)
category=Device Control
url=https://www.arduino.cc/reference/en/language/functions/usb/keyboard/
architectures=avr, samd, sam

--------------------

name=Keyboard
version=1.0.6
author=Arduino
maintainer=Arduino <info@arduino.cc>
sentence=Allows an Arduino board with USB capabilities to act as a Keyboard.
paragraph=This library plugs on the HID library. It can be used with or without other HID-based libraries (Mouse, Gamepad etc)
category=Device Control
url=https://www.arduino.cc/reference/en/language/functions/usb/keyboard/
architectures=avr, samd, sam, renesas_uno

Also now just read the thorough explanation by Ptillisch, and I see how this ambiguity might have arisen. (Also gives me some motivation to switch to v2!)

Anyway, bottom line: I deleted the entry 'Keyboard_Serial' from \libraries. Then ran IDE 2.3.6 which again offered to update Keyboard from 1.0.4 to 1.0.6. Accepting that gave a messsage that 1.0.6 was already installed (!) but no obscure error, so all is well.
:slightly_smiling_face:

@ptillisch

Many thanks, much appreciate your detailed explanation. See also my reply to @sonofcy, who spotted a detail I'd missed, and that quickly led to a fix.

I'm glad it is working now.

To clarify, the name of the library is the value of the name property. So the name of this library was "Keyboard", even though it happened to be installed in a folder named "Keyboard_Serial".

There is typically a correlation between the folder name and the library name because Library Manager and the Arduino IDE 2.x "Add .ZIP Library..." feature install the library in a folder named according to the library name, but that is only incidental to the library name.