Description
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:
- The sketch is in the root of a GitHub repository with an appropriate name, but when the user uses GitHub's "Download ZIP" feature to obtain the sketch, GitHub appends the Git ref to the folder name, causing a mismatch.
- The sketch developer used some 3rd party development software which does not enforce compliance.
- The sketch developer was simply sloppy in the way they packaged the sketch for distribution.
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
- Click the following link to download a demonstration sketch:
Foo.zip - Extract the downloaded file.
- Note that the extracted folder has the following structure:
Foo/ ├── Bar.ino └── Baz.ino
- Select File > Open... from the Arduino IDE menus.
- Select the
Bar.ino
file from the extractedFoo
folder.
🙂 A helpful dialog appears:
The file "Bar.ino" needs to be inside a sketch folder named "Bar".
Create this folder, move the file, and continue? - Click the "OK" button in the dialog.
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:
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:
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:
Examples of the current behavior causing problems:
- Software Compile errors Espressobar/arduino-grind-timer#2
- compile error functionreturnfunction/G27_Pedals_and_Shifter#16
- build error gillham/logic_analyzer#43
- Arduino IDE PhysicsAnonymous/CameraSlider#1
- https://forum.arduino.cc/t/eggduino-eggbot-undefined-reference-error-old-man-new-technologies/517103
- https://forum.arduino.cc/t/im-in-a-project-an-need-help-asap/560818
- https://forum.arduino.cc/t/where-is-the-problem/1378787
Related
- Move sketches to appropriately named folders livecast#1
- Move sketch to appropriately named subfolder adafruit/Standalone-Arduino-AVR-ISP-programmer#11
- Move sketch to appropriately named subfolder alitai/GS3-Chimera#1
- Move sketch to an appropriately named folder anklimov/lighthub#2
- Move sketch to appropriately named subfolder awgrover/even-gated-fade#1
- Move sketch to appropriately named subfolder avandalen/Spotwelder#2
- Move sketch to appropriately named subfolder bdring/TWANG32#2
- Move sketch to an appropriately named subfolder bitluni/ESP32CameraI2S#2
- Move sketch to appropriately named subfolder cnlohr/esplocalizer#9
- Move sketch to appropriately named subfolder CollinCunningham/Meditation_Trainer#1
- Move sketch to appropriately named subfolder Critters/TWANG#5
- Move sketch to an appropriately named folder dersimn/DevilRemote#1
- Move sketch to appropriately named subfolder DLehenbauer/arduino-midi-sound-module#1
- Move sketch to appropriately named subfolder Edzelf/ESP32-Radio#99
- Move sketch to appropriately named subfolder ffschm/SiPMTriggerFirmware#3
- Move sketch to appropriately named subfolder franck102/SerialUploader#1
- Move sketch to appropriately named subfolder Hieromon/ESPShaker#1
- Move sketch to appropriately named subfolder jasoncoon/esp8266-fastled-webserver#70
- Move sketch to appropriately named subfolder jbrazio/ardufocus#2
- Move sketch to an appropriately named folder JiriBilek/WiFiSpiESP#2
- Move sketch to appropriately named subfolder KrzysztofRak/RGB-Cube#1
- Move sketch to appropriately named subfolder latonita/arduino-canbus-monitor#6
- Move sketch to appropriately named subfolder laurb9/tiny_scope#22
- Move sketch to appropriately named subfolder marcocipriani01/Arduino-MoonLite-focuser#1
- Move sketch to appropriately named subfolder MarcFinns/AtmoScan#4
- Move sketch to appropriately named subfolder MhageGH/esp32_SoundRecorder#1
- Move sketch to appropriately named subfolder mxtommy/SigkSens#29
- Move sketch files to an appropriately named folder Napalm1432/ServoAnimator#1
- Move sketch to appropriately named subfolder NuclearPhoenixx/Lightmeter#1
- Move sketch to appropriately named subfolder olehs/r4sGate#1
- Move sketch to appropriately named subfolder papabricole/EggDuino#1
- Move sketch to appropriately named subfolder russp81/LEDLAMP_FASTLEDs#4
- Move sketch to appropriately named subfolder reivaxy/iotinator#1
- Move sketch to appropriately named subfolder Seeed-Studio/RFBee#4
- Move sketch to appropriately named subfolder tamntn/aquagrow-esp32#1
- Move sketch to appropriately named subfolder tillig/MarantzVolumeMonitor#1
- Move sketch to appropriately named subfolder TomNisbet/TommyPROM#1
- Move sketch to appropriately named subfolder wholder/DebugWireDebuggerProgrammer#1
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
- 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