arduino-language-server
arduino-language-server copied to clipboard
arduino-language-server does not error on failed compilation from arduino-cli
Bug Report
Current behavior
When starting the language server (I'm using neovim
's LSP client), the invocation to the arduino-cli
tool for a compilation step before calling clangd
can error out without crashing the language server. This causes an ambiguous behavior where the language server appears to be operating and waiting on clangd
, but has failed a necessary step to invoke the server.
Expected behavior
I would expect the language server to crash on failure to pre-process the ino
files into cpp
files and pass off to clangd
. It might even make sense to show an error message here that suggests there's an issue with the arduino-cli
involvement and to investigate there. For me, I had not installed the the platform core for the board.
The arduino-cli responds with a JSON object noting that the compiler has failed. I think on "success": false
the LS should exit and display a message.
Additionally (this should be an issue on the arduino-cli
project), it would be nice if the error message from the arduino-cli
tool made it to the LS. All the LS receives back is:
2021/06/27 00:24:32 arduino-cli output: {
"compiler_out": "",
"compiler_err": "",
"builder_result": null,
"success": false
}
however when compiling the code manually (not letting the LS do it for me), the error message is much more clear:
Error during build: platform not installed
Environment
- Language Server version (commit hash):
64a0e42a7a3d713629d3066d7555fb32cf19c3ec
- CLI version used (output of
arduino-cli version
):arduino-cli alpha Version: 0.18.3 Commit: d710b642 Date: 2021-05-14T12:36:58Z
- OS and platform:
Ubuntu 20.04.1 LTS
Additional context
Started logging.
2021/06/27 00:24:32 logging to /home/daniel/Projects/personal/arduino/OLED/inols.log
2021/06/27 00:24:32 Initial board configuration: { arduino:avr:uno}
2021/06/27 00:24:32 Language server build path: /tmp/arduino-language-server819982533
2021/06/27 00:24:32 Language server build sketch root: /tmp/arduino-language-server819982533/sketch
2021/06/27 00:24:32 IDE --> LS CL: REQUEST initialize 1:
2021/06/27 00:24:32 IDE --> initialize 1 locked
2021/06/27 00:24:32 IDE --> initialize 1 unlocked
2021/06/27 00:24:32 IDE <-- LS CL: ANSWER UNBOUND (1):
2021/06/27 00:24:32 INIT--- initializing workbench
2021/06/27 00:24:32 INIT--- locked
2021/06/27 00:24:32 --> initialize(file:///home/daniel/Projects/personal/arduino/OLED)
2021/06/27 00:24:32 running: /home/daniel/bin/arduino-cli --config-file /home/daniel/.arduino15/arduino-cli.yaml compile --fqbn arduino:avr:uno --only-compilation-database --clean --source-override /tmp/797020000 --build-path /tmp/arduino-language-server819982533 --format json /home/daniel/Projects/personal/arduino/OLED
2021/06/27 00:24:32 IDE --> LS CL: NOTIFICATION initialized:
2021/06/27 00:24:32 arduino-cli output: {
"compiler_out": "",
"compiler_err": "",
"builder_result": null,
"success": false
}
2021/06/27 00:24:32 INIT--- initializing workbench (done)
2021/06/27 00:24:32 INIT--- unlocked
2021/06/27 00:24:32 IDE --> initialized notif1 read-locked
2021/06/27 00:24:32 IDE --> initialized notif1 notification is not propagated to clangd
2021/06/27 00:24:32 IDE --> initialized notif1 read-unlocked
2021/06/27 00:24:32 IDE --> LS CL: NOTIFICATION textDocument/didOpen:
2021/06/27 00:24:32 IDE --> textDocument/didOpen notif2 locked
2021/06/27 00:24:32 IDE --> textDocument/didOpen notif2 (throttled: waiting for clangd)
2021/06/27 00:24:32 IDE --> textDocument/didOpen notif2 unlocked (waiting clangd)