Thanks so much for taking the time to investigate this and share your findings @alex_73! Having confirmation that this can cause the issue will enable me to suggest it as something for users to check without being afraid that I'm sending them off on a wild goose chase.
As for bringing this to the attention of the people who can fix it, your issue in the arduino/Arduino GitHub repository's issue tracker is a reasonablethe best place. Unfortunately, the Arduino IDE very popular piece of software maintained by only a couple developers so things to move slowly, but with patience I have seen many of the bug reports and feature requests I've made over the years resolved.
Arduino has been on a campaign for years now to move all the underlying functionality out of the Arduino IDE's Java code base and into a command line tool (which was originally
arduino-builder, but later became
Arduino CLI), eventually making the Java code base purely for the GUI components of the IDE. Arduino CLI is used by Arduino IDE, Arduino Web Editor, Arduino Pro IDE, and perhaps other 3rd party development software as time goes on. And of course it can be used directly. So this means that a fix or improvement made in Arduino CLI will eventually propagate to all the other Arduino development software. Development in the Arduino CLI is more active than in the Arduino IDE repository (though of course work done on Arduino CLI is also work on the IDE in the end).
I notice that when I try to update a library in Arduino CLI with a library file or folder open it does fail with a more helpful error message:
$ ./arduino-cli lib install Ethernet
Ethernet depends on Ethernet@2.0.0
Downloading Ethernet@2.0.0...
Ethernet@2.0.0 already downloaded
Installing Ethernet@2.0.0...
Replacing Ethernet@1.0.0 with Ethernet@2.0.0...
Error installing name:"Ethernet" versionRequired:"2.0.0" versionInstalled:"1.0.0": moving extracted archive to destination dir: rename C:\Users\per\Documents\Arduino\libraries\package-727220067\Ethernet-2.0.0 C:\Users\per\Documents\Arduino\libraries\Ethernet: Access is denied.
I see that the original library ends up removed after this occurs and I'm not sure that's the most ideal behavior, but the error message makes it clear that something went wrong and will at least give a clue as to what it was that happened. In some cases you could probably get a successful install on the second attempt.
So a feature request for a retry might actually be most appropriate in the
Arduino CLI issue tracker.