Skip to content

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

Closed
@per1234

Description

@per1234

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

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

Issue actions