Skip to content

First run "Arduino_BuiltIn" installation fails: "dir ... already exists" #1192

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 Jul 14, 2022 · 2 comments
Closed
3 tasks done
Assignees
Labels
conclusion: resolved Issue was resolved topic: CLI Related to Arduino CLI 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 Jul 14, 2022

Describe the problem

In order to allow users to get started with Arduino with the minimum amount of complexity, the Arduino IDE installs support for the most common boards and fundamental libraries automatically on the first run. This matches the experience provided by the Arduino IDE 1.x installation.

Users who were previously using Arduino IDE 1.x may already have some of these installed in the shared folders. Under certain conditions, this causes the installation of the "built-in" libraries to fail unexpectedly:

Failed to install library: Arduino_BuiltIn:1.0.0.
Error: 2 UNKNOWN: destination dir C:\Users\per\Documents\Arduino\libraries\SD already exists, cannot install

To reproduce

  1. Install one of the dependencies of the "Arduino_BuiltIn" library (e.g., "SD").
  2. Uninstall the "Arduino AVR Boards" platform.
  3. Select File > Quit from the Arduino IDE menus if it is running
  4. Rename or delete (:warning: cautiously) the following folder to simulate a first run:
    C:\Users\<user name>\AppData\Roaming\arduino-ide
    
  5. Start the Arduino IDE.
  6. When the Windows "User Account Control" dialogs for confirmation of the driver installation using "dpinst-amd64.exe" appear, promptly click the Yes button.
    ❗ The bug seems to be timing sensitive (likely requiring the library installation process to happen while the library and package index update is still in progress), the issue will not occur if the platform installation process is delayed excessively while blocked by this confirmation dialog.

🐛 Installation of the "Arduino_BuiltIn" library fails unexpectedly:

Tool arduino:[email protected] already installed
Downloading packages
Installing arduino:[email protected]
arduino:[email protected] installed
Installing arduino:[email protected]
arduino:[email protected] installed
Installing platform arduino:[email protected]
Configuring platform.
Platform arduino:[email protected] installed
Failed to install library: Arduino_BuiltIn:1.0.0.
Error: 2 UNKNOWN: destination dir C:\Users\per\Documents\Arduino\libraries\SD already exists, cannot install

Expected behavior

The library installation should be successful, skipping over the already installed "SD" library dependency:

Already installed [email protected]

Arduino IDE version

2.0.0-rc8-snapshot-fb690c9

Operating system

Windows

Operating system version

10

Additional context

I bisected the bug to a36524e (does not occur when using the build for 1073c3f).


This appears to be related to this Arduino CLI bug:

arduino/arduino-cli#1802

Even though the lack of awareness of external changes to the libraries reported at the link above is a bug in Arduino CLI, in this case there are no external changes to the libraries. So it seems there may also be a problem in the IDE that somehow results in the CLI being put into this state where its internal data about the libraries present does not match reality.

I was not able to reproduce this issue by running the equivalent operations via the Arduino CLI gRPC interface directly.


I have not been able to reproduce the issue on my Linux machine.


In the demo, I had the latest version of the SD library ("[email protected]") installed, so even after #1169 this would not be expected to fail.

Even under conditions where the library installation is expected to fail due to having an older version of one of the installed (e.g., "[email protected]"), it should fail with a different error message:

Error installing Arduino_BuiltIn: Library [email protected] is already installed, but with a different version: [email protected]

I suspected that the same problem might also occur for people doing updates on startup, as is the normal user flow now that notifications are shown for updatable library or platforms on startup (#1361).

If so, that would make the impact of the bug even more significant, since users will be performing updates regularly, whereas the first run library and platform installation operation will typically only occur once for each machine the IDE is used on.

However, I was not able to produce the bug in that way despite experimenting with different timings.

There is a report about the same error message here, triggered by an "INSTALL ALL" operation:

https://forum.arduino.cc/t/library-manager-is-empty/1002124/30


Reports of "destination dir \_\_\_ already exists" errors while installing/updating libraries:

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project topic: CLI Related to Arduino CLI labels Jul 14, 2022
@KurtE
Copy link

KurtE commented Dec 12, 2022

@kittaakos @per1234 - Not sure if this is the same issue, but as I mentioned up on the forum thread:
https://forum.arduino.cc/t/error-9-failed-precondition-library-arduino-builtin-1-0-0-not-found/1064331

I was wondering if the reason that hacked up Teensy Examples I was adding to my current teensy install was not showing up where I thought it should be, So I tried the sledgehammer approach mentioned in
#1030
To delete the directory: C:\Users<user name>\AppData\Roaming\arduino-ide\

And I then restarted the IDE. And the first time I ran it, it failed with:
`Error: 9 FAILED_PRECONDITION: Library ‘[email protected]’ not found'

I exited it and ran again, and it ran, with the console data starting off with:

Platform arduino:[email protected] already installed
Downloading [email protected]
[email protected]
Installing [email protected]`
...

I am guessing maybe some race condition or the like.
I retried the steps again this morning and it repeated.
I am running W11, and nightly build 1209
I have a reasonable number of boards installed:
image

@per1234 per1234 assigned per1234 and unassigned kittaakos Feb 28, 2023
@per1234
Copy link
Contributor Author

per1234 commented Feb 28, 2023

I believe this type of problem should be fixed by arduino/arduino-cli#1802 (introduced into Arduino IDE application by #1909)

@per1234 per1234 closed this as completed Feb 28, 2023
@per1234 per1234 added the conclusion: resolved Issue was resolved label Feb 28, 2023
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: CLI Related to Arduino CLI 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

3 participants