CLI: upload returns 0 on failure with third party package
- Dominant language
- Java
- Stars
- 14.6k
- Forks
- 7k
- PR merge metrics
- No merged PRs in 30d
Description
I have a strange problem. I am using the Arduino CLI tu build a sketch. With an official board, calling `arduino --upload --board arduino:avr:uno --port /dev/ttyUSB0 sketch.ino; echo $?` does return 1 when the upload failed, and 0 when it worked.
But with a third party package ([ESP8266](https://github.com/esp8266/Arduino)), the above command with `esp8266com:esp8266:nodemcuv2` always return 0, even on failure.
Digging in the code, I found out that the command exits with code 1 when [success](https://github.com/arduino/Arduino/blob/8e5b3553fc8b17c9bb96b56a5065ba90c7564816/arduino-core/src/processing/app/BaseNoGui.java#L491) is `false`, which should be the case when [the exit code of the upload command is different that 0](https://github.com/arduino/Arduino/blob/435fc323e0ab3b03bc5835e5309b5022bf57388a/arduino-core/src/cc/arduino/packages/Uploader.java#L129). But the fact is the [upload command](https://github.com/esp8266/Arduino/blob/master/platform.txt#L101) from the ESP8266 package, which uses `esptool`, exits with a non-0 (255) value when the upload fails (I just tested manually). Still, `arduino --upload` exits with 0.
I really don't understand what is happening...
Contributor guide
Research direction
Reproduce the failing `arduino --upload` command with the ESP8266 board package and compare its status with the official Uno upload. Trace exit-status handling through `arduino-core/src/processing/app/BaseNoGui.java`, `arduino-core/src/cc/arduino/packages/Uploader.java`, and the ESP8266 `platform.txt` upload command. Done means a failed third-party upload returns a nonzero CLI exit code while a successful upload returns zero.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- cli, embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100