Project Breaks Anytime I Save File

Apologies if this is an easy or obvious fix. I'm using the latest Arduino IDE on Mac. When I create a sketch or load an example sketch, it builds and uploads fine. However, the moment I save it, they break and can no longer be build / be uploaded to my Arduino/ESP32. It will throws errors about the boot loader, not being able to find the relevant libraries or has some other issue. It seems that saving the file breaks the links to some dependencies. If I create a new sketch and copy the code over, it works fine.

Here is an example output when I just tried to build and upload a saved file.

usage: esptool [-h]
[--chip {auto,esp8266,esp32,esp32s2,esp32s3beta2,esp32s3,esp32c3,esp32c6beta,esp32h2beta1,esp32h2beta2,esp32c2}]
[--port PORT] [--baud BAUD]
[--before {default_reset,usb_reset,no_reset,no_reset_no_sync}]
[--after {hard_reset,soft_reset,no_reset,no_reset_stub}]
[--no-stub] [--trace] [--override-vddsdio [{1.8V,1.9V,OFF}]]
[--connect-attempts CONNECT_ATTEMPTS]
{load_ram,dump_mem,read_mem,write_mem,write_flash,run,image_info,make_image,elf2image,read_mac,chip_id,flash_id,read_flash_status,write_flash_status,read_flash,verify_flash,erase_flash,erase_region,merge_bin,get_security_info,version}
...
esptool: error: unrecognized arguments: KY-024 Linear Hall.ino.bootloader.bin /Users/NateSF/Library/Arduino15/packages/esp32/hardware/esp32/2.0.5/tools/sdk/esp32/bin/bootloader_dio_80m.elf

exit status 2

Compilation error: exit status 2

version?

2.03

However, I have tried a handful of versions and they're all the same.

Hi @natesf. I see there is a bug in the ESP32 boards platform's esptool command pattern. The developers forgot to quote the filename. That means the command will break if the filename contains spaces as yours does.

This will never cause problems for Arduino IDE 1.x users because Arduino sketches are prohibited from having spaces in their names and Arduino IDE 1.x enforces that restriction. Unfortunately the Arduino IDE 2.x developers never got around to implementing the valid sketch name enforcement, which means that it is possible to create and use sketches with invalid names in Arduino IDE 2.x (arduino/arduino-ide#1599).

It is possible to add the missing quoting to the ESP32 boards platform configuration files, but that is a fairly complex operation. So my recommendation is for you to select File > Save As... from the Arduino IDE menus and save your sketch with a name that does not have any spaces in it. You will then be able to use the sketch without getting this error.

This is the most helpful and concise answer I have ever gotten on a forum. Thank you! I removed the spaces and it works.

You are welcome. I'm glad it is working now.

Regards,
Per

Keep in mind that there are many programs with such bug in the world. Never use spaces or national characters in filenames

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