I attempted a "verify" on a sketch; and I had not installed a needed library. Thus, the include file that I referenced in the first line of the sketch did not exist. The Verify immediately exited with a message indicating that it didn't know what was wrong. A better message would have been "Missing include file at line xxx".
Error code message was:
Compilation error: Error: 2 UNKNOWN: exit status 1
Thanks.
If you enable verbose output during compile, it will tell you
Using board 'promicro' from platform in folder: C:\Users\sterretje\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.12
Using core 'arduino' from platform in folder: C:\Users\sterretje\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Detecting libraries used...
"C:\\Users\\sterretje\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=8000000L -DARDUINO=10607 -DARDUINO_AVR_PROMICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x1b4f -DUSB_PID=0x9204 "-DUSB_MANUFACTURER=\"Unknown\"" "-DUSB_PRODUCT=\"SparkFun Pro Micro\"" "-IC:\\Users\\sterretje\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\sterretje\\AppData\\Local\\Arduino15\\packages\\SparkFun\\hardware\\avr\\1.1.12\\variants\\promicro" "C:\\Users\\sterretje\\AppData\\Local\\Temp\\arduino-sketch-CE22C7A4E842C457B61D122D4E5BACD3\\sketch\\random_techniques.ino.cpp" -o nul
Alternatives for sterretje.h: []
ResolveLibrary(sterretje.h)
-> candidates: []
Compilation error: Error: 2 UNKNOWN: exit status 1
Note that this was done with beta 7.
1 Like
Hi @oktype3tim . Thanks for your valuable feedback. I agree 1000% with your suggestions. The lack of the standard "No such file or directory" error message in this situation was found to be caused by a bug in the Arduino CLI tool the IDE uses under the hood to handle the sketch compilation process. That bug has now been fixed:
arduino:master
← arduino:scerza/enhance-compile-error-message
opened 08:11AM - 20 Oct 21 UTC
**Please check if the PR fulfills these requirements**
- [x] The PR has no du… plicates (please search among the [Pull Requests](https://github.com/arduino/arduino-cli/pulls)x
before creating one)
- [x] The PR follows
[our contributing guidelines](https://arduino.github.io/arduino-cli/latest/CONTRIBUTING/#pull-requests)
- [x] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
- [ ] `UPGRADING.md` has been updated with a migration guide (for breaking changes)
* **What kind of change does this PR introduce?**
Fixes an issue with `compile` command and related gRPC function.
- **What is the current behavior?**
If the user tries to compile a Sketch that includes a library that's not installed an error is printed to stderr.
The gRPC interface doesn't show the error at all.
```
$ arduino-cli compile -b arduino:avr:uno /home/alien/Arduino/Blink/Blink.ino --format json
/home/alien/Arduino/Blink/Blink.ino:1:10: fatal error: SD: No such file or directory
#include <SD>
^~~~
compilation terminated.
{
"compiler_out": "",
"compiler_err": "",
"builder_result": {
"build_path": "/tmp/arduino-sketch-302F70E5AC1B118F7324375770CFA163"
},
"success": false
}
```
* **What is the new behavior?**
Compilation of a Sketch that includes a library not installed now correctly prints the error to the expected error stream.
This also fixes the gRPC function.
```
$ arduino-cli compile -b arduino:avr:uno /home/alien/Arduino/Blink/Blink.ino --format json
{
"compiler_out": "",
"compiler_err": "/home/alien/Arduino/Blink/Blink.ino:1:10: fatal error: SD: No such file or directory\n #include \u003cSD\u003e\n ^~~~\ncompilation terminated.\n",
"builder_result": {
"build_path": "/tmp/arduino-sketch-302F70E5AC1B118F7324375770CFA163"
},
"success": false
}
```
- **Does this PR introduce a breaking change, and is
[titled accordingly](https://arduino.github.io/arduino-cli/latest/CONTRIBUTING/#breaking)?**
Nope.
* **Other information**:
None.
---
See [how to contribute](https://arduino.github.io/arduino-cli/latest/CONTRIBUTING/)
That fix is not yet in Arduino IDE 2.x, but it will be in one of the upcoming releases.
The mysterious "Error: 2 UNKNOWN" part of the error message has since been changed to "Error: 13 INTERNAL", which, if anything, is even worse! But there is a proposal now for improving on that situation here:
arduino:main
← arduino:scerza/clearer-errors
opened 03:49PM - 20 Oct 21 UTC
Before:

After:

1 Like
Thank you for the progress.
1 Like
system
Closed
February 23, 2022, 3:05pm
6
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.