IDE hangs on startup: "Unable to get Documents Folder: The system cannot find the file specified."

Thank you so much for this description, it helped me solve my issue.

After installing the 2.0.3 IDE then trying to open it, the IDE window would open up with the pulsing Arduino logo, it would sit like this until the computer crashed. After restarting the computer and opening the IDE again, then starting task manager I could see that it was in an endless loop, that carried on until it ran out of memory.
But it installed and worked perfectly on my daughters laptop. So I installed it on my desktop computer, and it worked perfectly...

I followed the process you provided and the powershell window took off, only stopping when I ended the task, in task manager. The following is what was being output in a continuous loop.

2023-01-05T01:39:28.046Z daemon ERROR Error: Unable to get Documents Folder: The system cannot find the path specified.
    at Socket.<anonymous> (C:\Users\Admin\AppData\Local\Programs\Arduino IDE\resources\app\node_modules\arduino-ide-extension\lib\node\arduino-daemon-impl.js:219:42)
    at Socket.emit (node:events:394:28)
    at addChunk (node:internal/streams/readable:312:12)
    at readableAddChunk (node:internal/streams/readable:287:9)
    at Socket.Readable.push (node:internal/streams/readable:226:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

The 1st line and the 2nd line told me what my problem was.

Both the desktop and the laptop "users "directory are redirected to an external harddrive, to save doubling up on files, this wasn't attached to the laptop when it was crashing.
But it was attached to the desktop, so I closed the IDE on the desktop, attached the external harddrive to the laptop and started the IDE, problem solved.

So thank you for your post I would never have found it otherwise.

Perhaps with the code being open source someone could code an error trap for this??
Cheers Darryl

Great work troubleshooting and solving that problem @ssducati. The poor user experience of Arduino IDE startup hanging due to the sketchbook location not being accessible was fixed after the time of the Arduino IDE 2.x release:

Access to the sketchbook folder is still required for the IDE to be fully functional, but the problem is now handled in a more user friendly manner: The IDE now starts up fully and shows an error message to communicate the problem to the user. The user can set a different sketchbook location in the IDE's preferences to resolve the issue if they are not able to restore access to the previous location.

That improvement will be in the next release of Arduino IDE.

Hello, I am having the same issue. I was able to locate the error lines myself, but I don't know how to resolve the issue.
This issue appears to be similar to another user on this thread, it can't locate the documents folder it's referencing. I'm not sure how to change the path to fix that issue though.

2023-01-11T20:30:06.078Z daemon INFO INFO[0000] Using config file: c:\Users\falco\.arduinoIDE\arduino-cli.yaml
INFO[0000] arduino-cli.exe version 0.29.0
INFO[0000] Executing `arduino-cli daemon`
{"IP":"127.0.0.1","Port":"63332"}

2023-01-11T20:30:06.127Z daemon INFO Unable to get Documents Folder: The system cannot find the file specified.

2023-01-11T20:30:06.128Z daemon ERROR Error: Unable to get Documents Folder: The system cannot find the file specified.
    at Socket.<anonymous> (C:\Program Files\Arduino IDE\resources\app\node_modules\arduino-ide-extension\lib\node\arduino-daemon-impl.js:219:42)
    at Socket.emit (node:events:394:28)
    at addChunk (node:internal/streams/readable:312:12)
    at readableAddChunk (node:internal/streams/readable:287:9)
    at Socket.Readable.push (node:internal/streams/readable:226:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
2023-01-11T20:30:06.128Z daemon INFO Starting daemon from C:\Program Files\Arduino IDE\resources\app\node_modules\arduino-ide-extension\build\arduino-cli.exe...
2023-01-11T20:30:06.185Z daemon INFO time="2023-01-11T13:30:06-07:00" level=error msg="Unable to get Documents Folder: The system cannot find the file specified."

2023-01-11T20:30:06.185Z daemon INFO INFO[0000] Using config file: c:\Users\falco\.arduinoIDE\arduino-cli.yaml
INFO[0000] arduino-cli.exe version 0.29.0
INFO[0000] Executing `arduino-cli daemon`
{"IP":"127.0.0.1","Port":"63333"}

2023-01-11T20:30:06.231Z daemon INFO Unable to get Documents Folder: The system cannot find the file specified.

2023-01-11T20:30:06.232Z daemon ERROR Error: Unable to get Documents Folder: The system cannot find the file specified.
    at Socket.<anonymous> (C:\Program Files\Arduino IDE\resources\app\node_modules\arduino-ide-extension\lib\node\arduino-daemon-impl.js:219:42)
    at Socket.emit (node:events:394:28)
    at addChunk (node:internal/streams/readable:312:12)
    at readableAddChunk (node:internal/streams/readable:287:9)
    at Socket.Readable.push (node:internal/streams/readable:226:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
2023-01-11T20:30:06.232Z daemon INFO Starting daemon from C:\Program Files\Arduino IDE\resources\app\node_modules\arduino-ide-extension\build\arduino-cli.exe...
2023-01-11T20:30:06.292Z daemon INFO time="2023-01-11T13:30:06-07:00" level=error msg="Unable to get Documents Folder: The system cannot find the file specified."

On startup, Arduino IDE creates a "sketchbook folder". This is the place where the IDE installs libraries, and also a convenient place to store your sketches. The default location of this sketchbook folder is a folder named Arduino created under your user documents folder.

Normally the documents folder is on your hard drive here:

C:\Users\falco\Documents\

However, if you are using Microsoft's OneDrive service, I believe the user documents folder is stored on OneDrive instead. In this case, starting the IDE without having OneDrive connected might cause this problem.

Are you aware of any problem such as this that might prevent the IDE from accessing your user documents folder?

Well, I actually had onedrive removed from my computer. I ran a powershell script to get rid of it. I also unlinked it before removing it. This was done before I installed arduino however.
There shouldn't be anything preventing it from accessing my user documents folder, other than the one drive version not existing.

I got it working, I reinstalled OneDrive and it rebuilt the missing folder. After uninstalling it again, it left the folder this time and now its working.

If you would like to not use OneDrive for your Arduino sketchbook (or not use OneDrive at all), you can change the location of the Arduino sketchbook to any folder you like. The Arduino sketchbook is the place where Arduino IDE installs libraries. It is also a convenient place to save your sketches (though you are welcome to save sketches to other locations if you prefer.

I'll provide instructions for setting a custom sketchbook location:

  1. Select File > Preferences... from the Arduino IDE menus.
    The "Preferences" dialog will now open.
  2. Click the Browse button to the right of the "Sketchbook location" field.
    The "Select new sketchbook location" dialog will now open.
  3. Select any folder for your sketchbook from the "Select new sketchbook location" dialog.
  4. Click the Choose button.
  5. Click the OK button in the "Preferences" dialog.

Thanks for the tip! So I can save my sketches wherever I want, just the libraries have to be in the correct folder? So if I were to change the sketchbook location I would have to move any libraries to the new location correct?

I was just looking into what you described and it looks like the default location is in an odd spot.


I can find the "Arduino IDE" Folder under C:/Program Files, is that where my sketchbook currently is? Based on this image, the sketchbook seems to be at the root of my computer.

Correct

Either that, or use Library Manager to reinstall them any libraries you need.

That is indeed odd. I can't tell for sure what the second character is in that field from looking at the screenshot; is the field set to \. (backslash, period). The second character looks more like a line connected to the backslash so maybe it is \_ (backslash, underscore)?

It’s a period! So it’s \.
If I press save on a new sketch, it opens to the Arduino IDE folder I mentioned earlier. However that folder doesn’t have any .lib files. So I’m uncertain where its sketchbook currently is. There is also no libraries folder within it. It does contain the .exe file for the IDE and a bunch of .dll files however.

I suppose it won’t hurt anything to just choose a sketchbook location and update my libraries, but it bothers me having files like that just floating around on my hard drive. Is there any way to locate exactly where the default location is?

I just tried it out and you were right about this.

So your libraries are in the C:\libraries folder.

This is what I did:

  1. Select File > Preferences from the Arduino IDE menus.
  2. Check the box next to "Show verbose output during: ☐ compilation".
  3. Click the OK button.
  4. Select File > New Sketch from the Arduino IDE menus.
  5. Select any library you installed via Library Manager from the Sketch > Include Library folder.
  6. Select Sketch > Verify/Compile from the Arduino IDE menus.
  7. Wait for the compilation to finish.

Now examine the contents of the black "Output" panel at the bottom of the Arduino IDE window. This will show the location of the libraries that were used to compile your sketch.

I chose the "Arduino_JSON" library for my experiment, so I saw this:

Using library Arduino_JSON at version 0.2.0 in folder: C:\libraries\Arduino_JSON 

Something to note is that there are several types of libraries that are installed in different ways.

The ones you install using Library Manager or the Sketch > Include Library > Add ZIP Library... feature are always installed in libraries subfolder of your sketchbook, but there are also the "built-in" libraries installed when you start Arduino IDE the first time (e.g., "Servo", "Mouse", "Ethernet"), which are installed at C:\Users\<username>\AppData\Local\Arduino15\libraries and the "platform bundled" libraries (e.g., "SPI", "Wire") that are installed along with the boards platforms, which are located under the C:\Users\<username>\AppData\Local\Arduino15\packages folder.

So don't get confused if you also see some libraries from those paths in the "Output" panel.

So turns out I didn’t have any libraries installed somehow. After I went and installed all the built in libraries you mentioned that should have come with the IDE installation, I was able to install another library and this generated the missing “libraries” folder in the “Arduino IDE” folder. Following your instructions showed that the sketchbook is in the new libraries folder.
The preferences tab didn’t change, so it’s still showing the same \. Should I change that to the libraries folder? Or the Arduino IDE folder?

You should change it, but not to either of those locations.

You should not set it to the libraries folder because libraries are installed to the libraries subfolder of the sketchbook folder, so if you did that, you would have a confusing situation where your sketches were installed under C:\libraries and your libraries were stored under C:\libraries\libraries.

You should not set it to the Arduino IDE folder because that would cause everything in your sketchbook to be lost every time you update to a new version of Arduino IDE. In addition, Windows places extra security restrictions on the C:\Program Files folder, where the IDE is often installed, which would interfere with the ability to install libraries and save sketches.

You should set the "Sketchbook location" preference to some convenient and safe folder. The default location is C:\users\<user name>\Documents\Arduino (where <user name> is your Windows user name. But you can put your sketchbook anywhere you like as long as it isn't in a location that will be deleted or that Arduino IDE can't write to.

Alright, thank you! You've been an immense help!

You are welcome. I'm going to keep an eye out to see if I spot other reports or occurrences of the IDE automatically setting the Sketchbook location preference to this \. value as that would definitely be considered a bug (but not if the user set it to that value themself).

If you experience the IDE setting the preference back to that value, and especially if you find a way to reproduce that bug, please comment here to let me know.

Regards,
Per

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.