arduino-ide icon indicating copy to clipboard operation
arduino-ide copied to clipboard

Failed to start language server

Open Wezz19 opened this issue 2 years ago • 3 comments

Describe the problem

  • No splashscreen at start
  • Language server fails to start
  • The text in the editor has no colors (probably caused by the language server)

The IDE is otherwise working. Verify, upload and serial monitor works normally.

To reproduce

Place a '#' in the IDE folder name and start the IDE.

Expected behavior

If '#' in the IDE folder name can't be supported in Windows due to limited support in other OS's then a notification to the user should make it clear that the IDE folder name contains an unsupported symbol.

Otherwise since the IDE seems to be running normally except for the language server then maybe it can be fixed to support '#' symbols in windows at least.

Arduino IDE version

nightly-20220628

Operating system

Windows

Operating system version

10

Additional context

2022-06-28 11:53:12 root INFO [d044d6a1-4348-4d71-813b-f0efe4e7ed33] Start of 0 plugins: 203.1 ms [Finished 3.714 s after frontend start]
2022-06-28 11:53:12 root INFO Starting language server: arduino:avr:uno
2022-06-28 11:53:12 root INFO Failed to start language server for arduino:avr:uno
2022-06-28 11:53:12 root INFO Starting language server: arduino:avr:uno
2022-06-28 11:53:12 root INFO Failed to start language server for arduino:avr:uno
2022-06-28 11:53:12 root INFO Starting language server: arduino:avr:uno
2022-06-28 11:53:12 root INFO Failed to start language server for arduino:avr:uno
2022-06-28 11:53:12 root INFO Starting language server: arduino:avr:uno
2022-06-28 11:53:12 root INFO Failed to start language server for arduino:avr:uno
2022-06-28 11:53:12 root INFO Starting language server: arduino:avr:uno
2022-06-28 11:53:12 root INFO Failed to start language server for arduino:avr:uno
2022-06-28 11:53:12 root INFO Starting language server: arduino:avr:uno
2022-06-28 11:53:12 root INFO Failed to start language server for arduino:avr:uno
2022-06-28 11:53:13 root INFO Frontend application start: 2637.1 ms [Finished 6.808 s after backend start]

Issue checklist

  • [X] I searched for previous reports in the issue tracker
  • [X] I verified the problem still occurs when using the latest nightly build
  • [X] My report contains all necessary details

Wezz19 avatar Jun 28 '22 11:06 Wezz19

Thanks for your report @Wezz19. I am able to reproduce the issue when using the Arduino IDE from such a path, but didn't have any problems when running Arduino Language Server directly from the command line with equivalent parameters. So this leads me to believe the issue is here in the Arduino IDE 2.x code base rather than in the Arduino Language Server code base.

per1234 avatar Jun 28 '22 15:06 per1234

  • The text in the editor has no colors (probably caused by the language server)

No. Syntax coloring is done by TextMate and is unrelated to any language features.

kittaakos avatar Jun 29 '22 08:06 kittaakos

This is caused by the theia-core module with incorrect assertion on Windows when the plugins path has a ‘#’.

r3inbowari avatar Sep 24 '22 00:09 r3inbowari

Great instructions, thanks!

it can be fixed to support '#' symbols in windows at least.

It's not a Windows-specific problem. I can reproduce it on macOS.

This is caused by the theia-core module with incorrect assertion on Windows when the plugins path has a ‘#’.

There may be a different reason.

  1. From the logs, I can see that the Arduino VS Code extension starts:
PluginDeployerEntryImpl {
    originId: 'local-dir:../plugins',
    pluginId: 'vscode-arduino-tools',
    _type: 0,
    map: Map(1) { 'package.json' => [Object] },
    changes: [ 'PluginVsCodeDirectoryHandler' ],
    acceptedTypes: [ 1 ],
    currentPath: '/Users/a.kitta/dev/git/arduino-ide/plugins/vscode-arduino-tools/extension',
    initPath: '/Users/a.kitta/dev/git/arduino-ide/plugins/vscode-arduino-tools',
    resolved: true,
    resolvedByName: 'LocalDirectoryPluginDeployerResolver',
    _rootPath: '/Users/a.kitta/dev/git/arduino-ide/plugins/vscode-arduino-tools'
  },
  1. I also see the Building Sketch in the status bar when I edit the sketch in the editor. The status bar update comes from the Arduino language-server.
  2. The LS log files were generated as expected. Use "arduino.language.log": true in the settings.json and check the log files. You can even tail them.

https://user-images.githubusercontent.com/1405703/211342513-5d099692-0f83-4821-9721-1c41506fcb3a.mp4

The LS works in other source files:

https://user-images.githubusercontent.com/1405703/211344387-66055405-b754-4fb7-bd7a-edb8abd02426.mp4

kittaakos avatar Jan 09 '23 15:01 kittaakos

From the LS logs:

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-language-server4280496927/.clangd","diagnostics":[]}}Content-Length: 178

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/a.kitta/Documents/Arduino/alma%23korte/alma%23korte.ino","version":1,"diagnostics":[]}}Content-Length: 112

{"jsonrpc":"2.0","id":1,"result":null,"error":{"code":-32603,"message":"-32001 Line value is out of range (2)"}}Content-Length: 36

This bug might belong to another issue tracker.

kittaakos avatar Jan 10 '23 07:01 kittaakos

I can also see that the URI is incorrectly encoded. Maybe @cmaglie can advise:

V[08:48:25.483] ASTWorker running EnumerateTweaks on version 1 of /private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-language-server4280496927/sketch/alma#korte.ino.cpp
I[08:48:25.483] --> reply:textDocument/codeAction("2") 86 ms, error: Line value is out of range (2)
V[08:48:25.483] >>> {"error":{"code":-32001,"message":"Line value is out of range (2)"},"id":"2","jsonrpc":"2.0"}

V[08:48:25.484] <<< {"id":"3","jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-language-server4280496927/sketch/alma#korte.ino.cpp"}}}

Here the URI must be

file:///private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-language-server4280496927/sketch/alma%23korte.ino.cpp

and NOT

file:///private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-language-server4280496927/sketch/alma#korte.ino.cpp

kittaakos avatar Jan 10 '23 07:01 kittaakos

  • The text in the editor has no colors (probably caused by the language server)

I could not reproduce this flaw. The rest is fixed: #1811

@Wezz19, could you please provide the steps to reproduce the syntax coloring problem?

kittaakos avatar Jan 10 '23 11:01 kittaakos

@kittaakos What I meant with "no colors" is this: Screenshot (127) Here the IDE (zip version) is run from a path containing a # "...\# Arduino IDE temp\arduino-ide_2.0.3_Windows_64bit\Arduino IDE.exe"

VS

here where the IDE (zip version) is run from a path with no special characters "...\Arduino IDE temp\arduino-ide_2.0.3_Windows_64bit\Arduino IDE.exe" Screenshot (129)

By the way, I think you forgot to edit the last line from your comment 8h ago. You probably meant this:

and NOT

file:///private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-language-server4280496927/sketch/alma#korte.ino.cpp

Not that it probably makes any difference anymore but just wanted to mention it =)

Wezz19 avatar Jan 10 '23 16:01 Wezz19

What I meant with "no colors" is this:

Thanks for the prompt reply. I will check it on Windows. I did not see any issues with the coloring on macOS.


By the way, I think you forgot to edit the last line from your comment 8h ago. You probably meant this:

and NOT file:///private/var/folders/z1/xkw1yh5n7rz4n8djprp1mdn80000gn/T/arduino-language-server4280496927/sketch/alma#korte.ino.cpp

Not that it probably makes any difference anymore but just wanted to mention it =)

Nice catch. I update it. 👍

kittaakos avatar Jan 10 '23 17:01 kittaakos

I am still seeing errors on Windows.

This correctly works after the go-lsp fix:

{"jsonrpc":"2.0","id":1,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///c%3A/Users/kittaakos/Documents/Arduino/min%23max/min%23max.ino"},"range":{"start":{"line":4,"character":2},"end":{"line":4,"character":2}},"context":{"diagnostics":[]}}}Content-Length: 170

{"jsonrpc":"2.0","id":2,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///c%3A/Users/kittaakos/Documents/Arduino/min%23max/min%23max.ino"}}}Content-Length: 40

{"jsonrpc":"2.0","id":"1","result":null}
>>>
Content-Length: 184

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///c%3A/Users/kittaakos/Documents/Arduino/min%23max/min%23max.ino","version":1,"diagnostics":[]}}
<<<
Content-Length: 40

{"jsonrpc":"2.0","id":"2","result":null}
>>>
Content-Length: 143

But the Arduino LS fails to publish the diagnostics from clagnd to IDE2. I do not yet know what's that, but the URI is not encoded, hence this is a bug:

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///C:/Users/kittaakos/AppData/Local/Temp/arduino-language-server3294049418/.clangd","diagnostics":[]}}Content-Length: 112

{"jsonrpc":"2.0","id":1,"result":null,"error":{"code":-32603,"message":"-32001 Line value is out of range (5)"}}Content-Length: 36

I will check it on Windows. I did not see any issues with the coloring on macOS.

I could not reproduce the coloring issue. I tend to split up this issue into two parts:

  • LS is not working if the main sketch file path contains a # due to incorrect URL path encoding,
  • syntax coloring is not working on Windows for whatever reason

kittaakos avatar Jan 11 '23 09:01 kittaakos

@Wezz19, could you please help us and try the tester build? I could reproduce the language server issues on both macOS and Windows. It's fixed, but I could not figure out what's causing the missing syntax coloring issue because I could not reproduce it. If you're willing to help, the PR is https://github.com/arduino/arduino-ide/pull/1811, and you can find documentation about the beta testing here: https://github.com/arduino/arduino-ide/blob/main/docs/contributor-guide/beta-testing.md#beta-testing-guide. Thank you!

kittaakos avatar Jan 11 '23 16:01 kittaakos

Okay I tested the zip version on two computers and got the same result on both when I added a # in the path: Screenshot (130) One computer has win10 and the other a freshly installed win11 with no Arduino IDE installed

Wezz19 avatar Jan 11 '23 19:01 Wezz19

Thanks for the quick reply, @Wezz19.

I cannot reproduce it. The tester build works fine on my Windows machine when there is a # in the sketch path.

Apparently, you have some other issues. The screenshot from https://github.com/arduino/arduino-ide/issues/1124#issuecomment-1379353370 shows there is no # in the sketch path unless you have changed your sketchbook location (directories.user) too.

I would appreciate some info from you. If you have time, please share with us.

  • Please let me know where you installed IDE2 from the ZIP. What's the full filesystem path?
  • What does IDE2 show when you hover over the editor tab?

https://user-images.githubusercontent.com/1405703/212001869-3debe970-7df7-4fbe-baea-ef02eb1b1a52.mp4

  • What does IDE2 show in the browser's console? You can check it on Windows with Ctrl + Alt + I and save the logs.

1124_01

  • What are in the logs? Please open a CMD.exe and start IDE2 with "Arduino IDE.exe", close IDE2, and share the full log.
  • Does the language server works on your side? When selecting any board with an installed platform, do you see syntax errors in the editor?

kittaakos avatar Jan 12 '23 07:01 kittaakos

I cannot reproduce it.

Now, I can reproduce it. You have a # in the path to the IDE2 and not a # in the path to the sketch. (From here: https://github.com/arduino/arduino-ide/issues/1124#issuecomment-1377546888)

INFO Failed to start language server for arduino:samd:adafruit_circuitplayground_m0 Error: The command 'arduino.languageserver.start' cannot be executed. There are no active handlers available for the command.
    at p.executeCommand (file:///C:/Users/kittaakos/Desktop/%23%20ide2%201124/resources/app/lib/bundle.js:2:2272619)
    at h.startLanguageServer (file:///C:/Users/kittaakos/Desktop/%23%20ide2%201124/resources/app/lib/bundle.js:2:8033988)

kittaakos avatar Jan 12 '23 09:01 kittaakos

There are two separate issues here:

  • there is a # in the sketch path. It should be fixed by #1811.
  • there is a # in the path to IDE2: https://github.com/eclipse-theia/theia/issues/12064

So this comment 👇 (https://github.com/arduino/arduino-ide/issues/1124#issuecomment-1256816102) is also accurate and valuable. Thank you!

This is caused by the theia-core module with incorrect assertion on Windows when the plugins path has a ‘#’.

kittaakos avatar Jan 12 '23 09:01 kittaakos

I could not find any easy way to provide a workaround for this flaw in IDE2. See why: https://github.com/eclipse-theia/theia/issues/12064#issuecomment-1380404909.

I tend to split up this issue into two parts:

Here is the follow-up issue: https://github.com/arduino/arduino-ide/issues/1815

#1811 fixes the bug when the sketch path contains a # and not IDE2 path has the #

kittaakos avatar Jan 12 '23 14:01 kittaakos