Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening invalid sketch via file association/command line fails silently #964

Closed
3 tasks done
Chose99 opened this issue Apr 22, 2022 · 5 comments · Fixed by #1563
Closed
3 tasks done

Opening invalid sketch via file association/command line fails silently #964

Chose99 opened this issue Apr 22, 2022 · 5 comments · Fixed by #1563
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@Chose99
Copy link

Chose99 commented Apr 22, 2022

Describe the problem

An Arduino sketch is a folder. This folder must contain an .ino file matching the folder name:

Foo/
└── Foo.ino

Users who have only worked with the single file sketches common in introductory tutorials and examples may have the impression that the file is the sketch. Sketch authors may distribute sketches as a file or inline code for convenience. Some distribution methods (e.g., GitHub's automatically generated ZIP files) may alter the name of the sketch folder. Any of these things may result in an invalid sketch due to the lack of alignment between folder and .ino file name.

For example:

Foo/
└── Bar.ino

If I start the Arduino IDE by opening a sketch that does not contain a .ino file matching the folder name (which is required for it to be considered valid), the IDE opens with the same behavior as it would without a sketch argument (last loaded sketches are opened).

To reproduce

  1. Create a sketch that does not meet the naming requirements.
    For example:
    Foo/
    └── Bar.ino
    
  2. Open the sketch directly, either from Windows "File Explorer" if you have .ino file association configured, or by running the IDE from the command line with the sketch path as an argument.
    & ".\Arduino IDE" "C:\Users\per\Documents\Arduino\Foo\Bar.ino"
    

🐛 The IDE does not communicate the problem to the user. The user is more likely to think something is wrong with the IDE than with the sketch.
🐛 The IDE does not offer to move the sketch file to an appropriately named folder

Expected behavior

The same behavior as when opening the file via File > Open in the Arduino IDE, as it works in Arduino IDE 1.x.

image

Arduino IDE version

Original report

2.0.0-rc6-nightly-20220422

Last verified with

2.0.1-snapshot-8380c82

Operating system

Windows

Operating system version

10.0.19044

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
@Chose99 Chose99 added the type: imperfection Perceived defect in any part of project label Apr 22, 2022
@per1234 per1234 changed the title File doesn't open if folder is has wrong name Opening invalid sketch via file association/command line fails silently Apr 22, 2022
@per1234 per1234 added the topic: code Related to content of the project itself label Apr 22, 2022
kittaakos pushed a commit that referenced this issue Oct 17, 2022
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

#964
kittaakos pushed a commit that referenced this issue Oct 18, 2022
Closes #964

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
kittaakos pushed a commit that referenced this issue Oct 18, 2022
Closes #964

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
kittaakos pushed a commit that referenced this issue Oct 18, 2022
Closes #964

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
kittaakos pushed a commit that referenced this issue Oct 18, 2022
Closes #964

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
@kittaakos
Copy link
Contributor

2. Open the sketch directly, either from Windows "File Explorer" if you have .ino file association configured, or by running the IDE from the command line with the sketch path as an argument.
& ".\Arduino IDE" "C:\Users\per\Documents\Arduino\Foo\Bar.ino"

For the record, it does not work with valid sketches either.

I am using IDE2 2.0.0 version:

Version: 2.0.0
Date: 2022-09-14T07:08:28.861Z
CLI Version: 0.27.1 [a900cfb2]

Copyright © 2022 Arduino SA

My workspace:

% ls -al ./my_workspace                                                     
total 0
drwxr-xr-x   3 a.kitta  staff   96 Oct 19 10:41 .
drwx------@ 19 a.kitta  staff  608 Oct 19 10:38 ..
-rw-r--r--   1 a.kitta  staff    0 Oct 19 10:41 my_workspace.ino

Opening the sketch does not work with any of these:

/Applications/Arduino\ IDE.app/Contents/MacOS/Arduino\ IDE "./my_workspace/"
/Applications/Arduino\ IDE.app/Contents/MacOS/Arduino\ IDE "./my_workspace/my_workspace.ino"
/Applications/Arduino\ IDE.app/Contents/MacOS/Arduino\ IDE ./my_workspace/
/Applications/Arduino\ IDE.app/Contents/MacOS/Arduino\ IDE ./my_workspace/my_workspace.ino

IDE2 forcefully tries to restore the opened sketches from the previous session.

@per1234
Copy link
Contributor

per1234 commented Oct 19, 2022

it does not work with valid sketches either.

Try it with the absolute sketch path @kittaakos. I get the same results from a relative path, but it works fine with the absolute sketch path.

@kittaakos
Copy link
Contributor

Thank you for verifying it on Windows. It does not work with absolute path either on macOS. I tried these:

% ls -al ./my_workspace 
total 0
drwxr-xr-x   3 a.kitta  staff   96 Oct 19 10:41 .
drwx------@ 16 a.kitta  staff  512 Oct 19 11:56 ..
-rw-r--r--   1 a.kitta  staff    0 Oct 19 10:41 my_workspace.ino
% /Applications/Arduino\ IDE.app/Contents/MacOS/Arduino\ IDE /Users/a.kitta/Desktop/my_workspace 
% /Applications/Arduino\ IDE.app/Contents/MacOS/Arduino\ IDE /Users/a.kitta/Desktop/my_workspace/my_workspace.ino

Electron requires different file-association implementations for macOS and other OSs. I bet that is causing the problem in IDE2, but I do not understand why relative workspace files are broken on Windows. It should work. See here.

This is just a guess, but I think a good one. The .ino file association implementation overrules Theia's default CLI contribution:

  • on macOS, and that's why it does not work. The frontend does not have the chance to pick up the workspace path from the CLI, but IDE2 forcefully tries to restore all previously opened sketches.
  • on Windows and Linux, the default CLI contribution is also shadowed, but it's partially working with an absolute workspace root path.

@per1234
Copy link
Contributor

per1234 commented Oct 19, 2022

I checked on Linux and got the same result as on Windows: the sketch opens when I pass the absolute path via a command line argument, but it does not open when I pass the relative path.

Even with absolute path, it only works when I pass the path to the .ino file. It does not work when I pass the path to the sketch folder. Unfortunate, but this is also how Arduino IDE 1.x works so I think the users are accustomed to that quirk.

@kittaakos
Copy link
Contributor

It does not work when I pass the path to the sketch folder.

I will fix this too as part of #1563

kittaakos pushed a commit that referenced this issue Oct 19, 2022
Log IDE2 version on start.

Closes #964
Closes #1484

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
kittaakos pushed a commit that referenced this issue Oct 20, 2022
Log IDE2 version on start.

Closes #964
Closes #1484

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
kittaakos pushed a commit that referenced this issue Oct 20, 2022
Log IDE2 version on start.

Closes #964
Closes #1484

Co-authored-by: Alberto Iannaccone <a.iannaccone@arduino.cc>
Co-authored-by: Akos Kitta <a.kitta@arduino.cc>

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
kittaakos pushed a commit that referenced this issue Oct 26, 2022
Log IDE2 version on start.

Closes #964
Closes #1484

Co-authored-by: Alberto Iannaccone <a.iannaccone@arduino.cc>
Co-authored-by: Akos Kitta <a.kitta@arduino.cc>

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
kittaakos pushed a commit that referenced this issue Oct 26, 2022
Log IDE2 version on start.

Closes #964
Closes #1484

Co-authored-by: Alberto Iannaccone <a.iannaccone@arduino.cc>
Co-authored-by: Akos Kitta <a.kitta@arduino.cc>

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
@per1234 per1234 added the conclusion: resolved Issue was resolved label Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants