Communicate to the user cause of debugger not starting with uncompiled sketch
Describe the current behavior
The Arduino IDE integrated debugger requires the sketch binary produced by compilation of the sketch. The path to this file is provided to the debugger via the launch.json file that is automatically generated by the IDE when the user clicks the "Start Debugging" button on the button bar.
For this reason, the debugger can not be initialized if the user didn't know or remember to compile the sketch before clicking the button.
🙁 The IDE does not communicate this problem to the user other than that clicking the "Start Debugging" button has no effect.
To reproduce
- Select File > New from the Arduino IDE menus.
- Select Tools > Board > Arduino SAMD (32-bits ARM Cortex-M0+) Boards > Arduino Zero (Programming Port from the Arduino IDE menus. There is no need to have a Zero connected to your computer for this demo.
- Click the "Start Debugging" button on the button bar.
- Wait as long as you need to feel certain that nothing is going to happen.
🙁 There is no feedback from the IDE that the debugger couldn't start, and no indication of what is wrong.
Describe the request
Display a notification when the IDE fails to initialize the debugger. Explain that they must compile or upload the sketch first.
Desktop
- OS: Windows 10, Ubuntu 20.04
- Version: 2.0.0-rc3-snapshot.759b410 Date: 2022-01-31T13:15:29.574Z CLI Version: 0.20.2 [13783819]
Additional context
The "vscode-arduino-tools" extension that generates the debugger configuration knows of this issue and even attempts to generate an error message:
https://github.com/arduino/vscode-arduino-tools/blob/5382501e0b35f500bc8dcc9ffe877cdf37935552/src/extension.ts#L118
However, this error message is never shown to the user by the IDE.
The poor user experience of no feedback in this situation is exacerbated by the fact that there is also no immediate feedback after clicking the "Start Debugging" button when all is well, and it takes quite some time for the debugger to finally start up. In addition, you are punished if you get impatient and click the button multiple times. So the IDE trains you to expect some indeterminate wait for the debugger, and this causes you to wait quite some time before finally concluding something must be wrong (still with no indication of what went wrong).
Starting from https://github.com/arduino/arduino-ide/commits/112153fb965f63d952d126c8244cd3f84f0a1a1b, there is now a notification under these conditions:
Error getting Debug info: Compiled sketch not found in C:\Users\per\AppData\Local\Temp\arduino-sketch-C8D178233C0D418F572FEE5FAF047395
However, this is not the notification from vscode-arduino-tools mentioned above, which would look like:
Sketch <sketch path> was not compiled. Please compile the sketch and start debugging again.
The latter communicates the problem much more clearly, but also relies on a fragile pattern matching against the human readable error message from Arduino CLI (which is the error that is now shown in the notification).
So I'm not sure whether or not this should be considered resolved. If the effort is going to be made to maintain custom notification code in arduino/vscode-arduino-tools, then the IDE should take advantage of it. If the custom notification is not going to be used, then that code should be removed from arduino/vscode-arduino-tools and we can settle for the less clear, but still acceptable notification already shown by the IDE.
However, this is not the notification from vscode-arduino-tools mentioned above, which would look like:
There is a bug here. The string match of the message fragment must be lower-cased, and then users would get the expected notification:

Since IDE2 will require changes in the VS Code extension anyway, I decided to do the following:
- if any error occurs when generating the
launch.jsoncontent for the debugger, the VS Code extensions will throw the error as is, which will be handled on IDE2's side. - IDE2 will be able to show whatever error message it wants with possible command actions, such as
verifythis sketch. - There is one down part of this approach the CLI will throw such error message:
Compiled sketch not found in C:\Users\per\AppData\Local\Temp\arduino-sketch-C8D178233C0D418F572FEE5FAF047395. IDE2 has to know how the builder generates the temp folder for the sketch on verify: https://github.com/arduino/arduino-cli/blob/c0d4e4407d80aabad81142693513b3306759cfa6/arduino/sketch/sketch.go#L296-L306 and must handle FS paths vs. URI conversion.