Hi luigi.
I see there are two separate problems:
"Could not install Arduino AVR platform: Could not find platform" error on first run
https://youtu.be/feIdo2jSMdA?t=32
On the first run of a fresh installation, the Arduino IDE automatically installs the "Arduino AVR Boards " platform of the popular Uno, Mega, Leonardo, etc. boards.
You can see that around the same time the IDE is also downloading and verifying some index files. I believe what happens is that if there is a very specific timing of those two operations it bugs out and you get this error. I have encountered something similar, except with the libraries that are installed on the first run:
opened 04:16PM - 14 Jul 22 UTC
topic: code
type: imperfection
topic: CLI
### 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**"](https://github.com/arduino-libraries/Arduino_BuiltIn) library (e.g., ["**SD**"](https://github.com/arduino-libraries/SD)).
1. Uninstall the "**Arduino AVR Boards**" platform.
1. Select **File > Quit** from the Arduino IDE menus if it is running
1. Rename or delete (:warning: cautiously) the following folder to simulate a first run:
```
C:\Users\<user name>\AppData\Roaming\arduino-ide
```
1. Start the Arduino IDE.
1. When the Windows "**User Account Control**" dialogs for confirmation of the driver installation using "dpinst-amd64.exe" appear, promptly click the <kbd>**Yes**</kbd> 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:
```text
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:
```text
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 https://github.com/arduino/arduino-ide/commit/a36524e02ab5fbc2ef333ff67a047dfe5718b306 (does not occur when using the build for https://github.com/arduino/arduino-ide/commit/1073c3fc7d9350532da40636aefc858c0a569e5f).
---
This appears to be related to this Arduino CLI bug:
https://github.com/arduino/arduino-cli/issues/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 https://github.com/arduino/arduino-ide/pull/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:
```text
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 (https://github.com/arduino/arduino-ide/pull/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:
- https://forum.arduino.cc/t/library-manager-is-empty/1002124/30
- https://forum.arduino.cc/t/question-on-2-0-0-ide/1035203
### Issue checklist
- [X] I searched for previous reports in [the issue tracker](https://github.com/arduino/arduino-ide/issues?q=)
- [X] I verified the problem still occurs when using the latest [nightly build](https://github.com/arduino/arduino-ide#nightly-builds)
- [X] My report contains all necessary details
There is also a report of a similar problem that happened when updating libraries:
https://forum.arduino.cc/t/library-manager-is-empty/1002124/30
I hope the Arduino IDE developers will find a fix for this class of bugs, but the good news in this case is I see from the video that the process was successful the second time you started the IDE, so this is not something you need to worry about.
https://youtu.be/feIdo2jSMdA?t=64
"Invalid sketchbook location: /home/luigi/Arduino" error in Preferences dialog
https://youtu.be/feIdo2jSMdA?t=92
The sketchbook folder is used for the installation of libraries and is also a convenient location to save your sketches. The Arduino IDE 2.x does not currently create this folder automatically on startup. This bug is tracked here:
opened 03:58AM - 16 Sep 22 UTC
closed 07:10AM - 21 Sep 22 UTC
conclusion: resolved
topic: code
type: imperfection
### Describe the problem
The "sketchbook" folder is a storage location for se… veral types of resources used by the Arduino IDE and the user. In addition to its use for global library installations, it is the preferred location for saving sketches due to the integration of this folder with the "**Sketchbook**" view and **File > Sketchbook** menu.
Currently, the Arduino IDE does not create the sketchbook folder at the default location if it does not already exist (which it won't for first time users).
🐛 The user is prevented from changing preferences until they have selected a sketchbook folder location that exists (https://github.com/arduino/arduino-ide/issues/1444).
🐛 The **Save As...** dialog will not encourage saving sketches to the preferred location.
### To reproduce
1. Rename or delete your sketchbook folder (you can find the location by checking the "**Sketchbook location**" preference in the IDE).
1. Start the Arduino IDE.
1. Select "**File > Preferences**" from the Arduino IDE menus.
1. Modify the "**Editor font size**" value.
1. Click the <kbd>OK</kbd> button.
🐛 The preference can not be changed because the button is disabled.
1. Click the <kbd>CANCEL</kbd> button.
1. Select **File > Save as** from the Arduino IDE menus.
1. A path without any enhanced treatment is selected in the "**Save sketch folder as...**" dialog.
### Expected behavior
Sketchbook folder is created on IDE startup if it does not exist.
If it is not possible to create the sketchbook folder (e.g., it is on a removable or cloud drive that is not currently connected), the IDE should clearly communicate the problem to the user.
### Arduino IDE version
2.0.0-snapshot-4e590ab
### Operating system
Windows
### Operating system version
10
### Additional context
Prior to https://github.com/arduino/arduino-ide/pull/1370, the sketchbook folder was generated on first run as a side effect of the "**Arduino_Builtin**" library installation.
---
As an alternative to automatically creating the sketchbook on startup, the current behavior of the "**Preferences**" dialog could be changed.
Currently, the "**OK**" button is disabled if the path set via the "**Sketchbook location**" preference does not exist. This is the most significant impact of the sketchbook folder not being created.
So if that check for a valid sketchbook path was removed, the remaining impact would be that saving a sketch to a sketchbook that doesn't exist is very complicated for the beginners who are most likely to experience this bug.
I looked for any other impacts of a missing sketchbook folder and didn't find one. Arduino CLI automatically creates the folder on any operation that requires it (Library Manager installation, "Add ZIP Library").
---
The combination of this bug with https://github.com/arduino/arduino-ide/issues/1259 results in an especially poor user experience.
---
Arduino IDE 1.x creates the sketchbook folder on startup.
### Issue checklist
- [X] I searched for previous reports in [the issue tracker](https://github.com/arduino/arduino-ide/issues?q=)
- [X] I verified the problem still occurs when using the latest [nightly build](https://github.com/arduino/arduino-ide#nightly-builds)
- [X] My report contains all necessary details
The developers have already prepared a fix, which will be in the next release. But for now you should simply create the folder by following these instructions:
If you have the "Preferences " dialog open in the Arduino IDE, click the "CANCEL " button.
Create an empty folder at this path: /home/luigi/Arduino
You can use your file manager program to create that folder, or run this command from the command line terminal if you prefer:
mkdir /home/luigi/Arduino
Please let us know if you have any questions or encounter any other problems.