Skip to content

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

Closed
@per1234

Description

@per1234
Contributor

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:arduinoOTA@1.3.0 already installed
Downloading packages
Installing arduino:avr-gcc@7.3.0-atmel3.6.1-arduino7
arduino:avr-gcc@7.3.0-atmel3.6.1-arduino7 installed
Installing arduino:avrdude@6.3.0-arduino17
arduino:avrdude@6.3.0-arduino17 installed
Installing platform arduino:avr@1.8.5
Configuring platform.
Platform arduino:avr@1.8.5 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 SD@1.2.4

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 ("SD@1.2.4") 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., "SD@1.2.3"), it should fail with a different error message:

Error installing Arduino_BuiltIn: Library SD@1.2.4 is already installed, but with a different version: SD@1.2.3

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
    I verified the problem still occurs when using the latest
    My report contains all necessary details

Activity

added
topic: codeRelated to content of the project itself
type: imperfectionPerceived defect in any part of project
topic: CLIRelated to Arduino CLI
on Jul 14, 2022
KurtE

KurtE commented on Dec 12, 2022

@KurtE

@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 ‘Arduino_BuiltIn@1.0.0’ not found'

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

Platform arduino:avr@1.8.6 already installed
Downloading Keyboard@1.0.4
Keyboard@1.0.4
Installing Keyboard@1.0.4`
...

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 commented on Feb 28, 2023

@per1234
ContributorAuthor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

conclusion: resolvedIssue was resolvedtopic: CLIRelated to Arduino CLItopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @kittaakos@KurtE@per1234

      Issue actions

        First run "Arduino_BuiltIn" installation fails: "dir ... already exists" · Issue #1192 · arduino/arduino-ide