Skip to content

IDE does not start when last project is on unavailable network path #2166

Closed
@Niko-O

Description

@Niko-O

Describe the problem

When starting Arduino IDE 2.1.1, it tries to restore the last opened project. If that project is on a shared folder that is now unavailable, the IDE never starts. It does not show an error message. It does not even open a window.
Starting the IDE from CMD prints this:

Failed to start the electron application.
[Error: UNKNOWN: unknown error, stat '\\192.168.1.20\Share\Test\main\main.ino'] {
  errno: -4094,
  code: 'UNKNOWN',
  syscall: 'stat',
  path: '\\\\192.168.1.20\\Share\\Test\\main\\main.ino'
}

I had to remove the workspace-object from %AppData%\arduino-ide\config.json, then it started again.

To reproduce

  1. Create a new sketch
  2. Save it on a shared folder (e.g. on a NAS or on a folder shared from a different computer)
  3. Close Arduino IDE
  4. Unplug your network cable / disconnect WiFi
  5. Start Arduino IDE

Expected behavior

The IDE should start up, and show a new, empty project (possibly the default sketch that's also shown when clicking on File -> New Sketch). It should ideally show a warning that the previous project (insert path here) could not be reopened.

Arduino IDE version

2.1.1

Operating system

Windows

Operating system version

Windows 10

Additional context

Additional reports

Related

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

Activity

self-assigned this
on Aug 18, 2023
kittaakos

kittaakos commented on Aug 18, 2023

@kittaakos
Contributor

Thanks for the report and for collecting the forum posts. It was super helpful to locate the error:

const sketchFolderPath = await isAccessibleSketchPath(
resolvedPath,
true
);

To get an UNKNOWN error for syscall: 'stat' on Windows:

const fs = require('fs');
const start = performance.now();
try {
  fs.statSync('\\\\10.0.0.200\\path');
} finally {
  console.log('took', performance.now() - start, 'ms');
}

IDE2 must handle UNKNOWN code here:

if (ErrnoException.isENOENT(err)) {
return undefined;
}
throw err;

The timeout is ~25s on my Windows env; IDE2 must use slow tests.

nodejs/node#19965 (comment)

Another topic IDE2 should consider is this:

* The `path` must be an absolute, resolved path. This method does not handle EACCES (Permission denied) errors.

So if, for whatever reason, IDE2 cannot open a sketch due to EACCESS, the app will hang at startup.

added a commit that references this issue on Aug 18, 2023
bed3741
added a commit that references this issue on Aug 18, 2023
eb2a1d9
per1234

per1234 commented on Aug 18, 2023

@per1234
Contributor

Despite quite some efforts, I was never able to reproduce this due to #1797. I'm actually quite mystified as to how @Niko-O managed that.

However, I had seen some reports on the forum of a similar problem involving restoring sketches from normal paths. I wasn't able to reproduce it by saving a sketch to a removable drive, then removing the drive before restarting the IDE. However, I noticed the pattern that the sketch was on D:\ in both reports. This is interesting because that drive letter is typically associated with a DVD drive on computers that have one. My hypothesis was that attempting to restore a sketch from a DVD drive without a disc produced an unusual exception Arduino IDE was not designed to handle. So I tried it out and sure enough I was able to produce a hang under these conditions:

To reproduce

Equipment

  • DVD drive on your computer
  • A removable USB drive

Set up

  1. Open the Windows "Start" menu.
  2. Type create and format hard disk partitions in the search field.
  3. Select "Create and format hard disk partitions" from the list of search results.
    The "Disk Management" window will open.
  4. Find the "CD-ROM" drive in the bottom panel of the "Disk Management" window.
  5. Note the drive letter that is assigned to the "CD-ROM" drive.
    I'll refer to it as D:\ through the rest of these instructions, but the demo will work for any drive letter.
  6. Right click on the drive.
    A context menu will open.
  7. Select "Change Drive Letter and Paths..." from the context menu.
    The "Change Drive Letter and Paths for ..." dialog will open.
  8. Click the "Change..." button in the dialog.
  9. Select any free drive letter from the "Assign the following drive letter" menu.
  10. Click the "OK" button
  11. Click the "Yes" button in the confirmation dialog.
  12. Connect the removable drive to your computer.
  13. If the drive was not automatically assigned the D:\ drive letter, repeat the above procedure via the "Disk Management" utility to assign it D:\.
  14. Start Arduino IDE if it is not already running.
  15. Select File > Save As..." from the Arduino IDE menus.
  16. Save the sketch on the removable drive.
  17. Close all Arduino IDE windows other than the one with the sketch you just saved.
  18. Wait a few seconds.
  19. Select File > Quit from the Arduino IDE windows.
  20. Eject and disconnect the removable drive from your computer.
  21. Open the Windows "Start" menu.
  22. Type create and format hard disk partitions in the search field.
  23. Select "Create and format hard disk partitions" from the list of search results.
    The "Disk Management" window will open.
  24. Find the "CD-ROM" drive in the bottom panel of the "Disk Management" window.
  25. Right click on the drive.
    A context menu will open.
  26. Select "Change Drive Letter and Paths..." from the context menu.
    The "Change Drive Letter and Paths for ..." dialog will open.
  27. Click the "Change..." button in the dialog.
  28. Select "D" from the "Assign the following drive letter" menu.
  29. Click the "OK" button
  30. Click the "Yes" button in the confirmation dialog.
  31. Eject the disk from the DVD drive if one is loaded.

Demo

  1. Start Arduino IDE.

🐛 The IDE never starts.

The logs show the error:

Restoring workspace roots: d:\SavedOnD
Failed to start the electron application.
[Error: UNKNOWN: unknown error, stat 'd:\SavedOnD'] {
  errno: -4094,
  code: 'UNKNOWN',
  syscall: 'stat',
  path: 'd:\\SavedOnD'
}

Arduino IDE version

69ae38e

Operating system

Windows

Operating system version

11

Niko-O

Niko-O commented on Aug 18, 2023

@Niko-O
Author

I'm actually quite mystified as to how @Niko-O managed that.
grafik

If opening a project form a path that starts with \\Server\Share does not work for you, mounting it as a network drive might work.

per1234

per1234 commented on Aug 19, 2023

@per1234
Contributor

mounting it as a network drive might work.

Thanks for the suggestion. I tried that, but was not able to reproduce the fault via this approach of opening a sketch from a path on a network drive (which is not subject to #1797) and then causing the IDE to attempt to restore the sketch from that path on a startup after I had disconnected the drive.

Instead of producing the fault reported here as I hoped, the IDE only exhibited the intended behavior of falling back on opening a new sketch under these conditions, just the same as it does if it attempts to restore a sketch from a path on a standard removable drive that was removed from the computer since the previous IDE session.

Niko-O

Niko-O commented on Aug 19, 2023

@Niko-O
Author

@per1234
I suspect that's because when you unmount the drive, Windows knows for sure that anything inside that path is definitely not accessible.
If I keep the drive mounted but unplug the network connection and then start the IDE, I can reproduce the issue.

Failed to start the electron application.
[Error: UNKNOWN: unknown error, stat 'x:\Test\main'] {
  errno: -4094,
  code: 'UNKNOWN',
  syscall: 'stat',
  path: 'x:\\Test\\main'
}

(I find it a bit weird that the drive letter is small here. Windows should not care, but it's weird nontheless.)

added a commit that references this issue on Aug 20, 2023
b256655
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @kittaakos@Niko-O@per1234

    Issue actions

      IDE does not start when last project is on unavailable network path · Issue #2166 · arduino/arduino-ide