Multi-file sketches broken by name mismatch resolution feature #2727
Labels
topic: code
Related to content of the project itself
type: imperfection
Perceived defect in any part of project
Describe the problem
Arduino sketches may consist of multiple code files:
https://arduino.github.io/arduino-cli/dev/sketch-specification/#additional-code-files
The Arduino sketch folder must have a name matching that of the primary sketch file:
https://arduino.github.io/arduino-cli/dev/sketch-specification/#primary-sketch-file
Unfortunately some of the sketches that are published online do not comply, which might occur for reasons such as:
If the user opens a sketch which does not have a matching folder name, Arduino IDE helpfully offers to move the sketch to a folder with a matching name to make the sketch valid so that it can be opened in Arduino IDE.
🐛 The feature only moves the single file the user selected from the "Open" dialog, which breaks sketches that consist of multiple code files.
To reproduce
Foo.zip
Bar.ino
file from the extractedFoo
folder.🙂 A helpful dialog appears:
A sketch named "Bar" opens in a new sketch window.
🐛 The additional code file
Baz.ino
was not moved to the new folder. The sketch will not compile because it is incomplete due to the missing file.Expected behavior
The feature for helping the user to resolve an invalid sketch folder name does not break multi-file sketches.
Arduino IDE version
2.3.6
Operating system
All
Operating system version
Any
Additional context
The same problem was also present in Arduino IDE 1.x. The initial proposal was to make it move all files in the original folder to the new folder:
arduino/Arduino#6404
However, the problem with that solution is that the user might have downloaded a single sketch folder into a folder that contains various irrelevant files. In this case, Arduino IDE moving all the irrelevant files to the new sketch folder would not be appropriate.
An alternative proposal was then made to simply remove the feature:
arduino/Arduino#7904
And then a 3rd proposal which attempted to make the feature deciding when it should copy the single file or all files to the new folder:
arduino/Arduino#7909
Examples of the current behavior causing problems:
Related
Workaround
Manually rename the folder to match the name of the primary
.ino
file before opening the sketch in Arduino IDE.Keywords
"rename"
Issue checklist
The text was updated successfully, but these errors were encountered: