Kotlin Language Client client: couldn't create connection to server.
every time i open a file ending .kt this bug happened to me it was working just fine a day a go maybe because of a vscode update but idk
version JDK: java 17.0.12 2024-07-16 LTS
version of kotlin: 2.0.0-release-341 (JRE 17.0.12+8-LTS-286)
version extenstion : 0.2.35
Error message:
[Error - 9:46:46 PM] Kotlin Language Client client: couldn't create connection to server.
Error: spawn EINVAL
at ChildProcess.spawn (node:internal/child_process:421:11)
at Object.spawn (node:child_process:799:9)
at c:\Users\accompagnant.vscode\extensions\fwcd.kotlin-0.2.35\dist\extension.js:2:763567
at async k.createConnection (c:\Users\accompagnant.vscode\extensions\fwcd.kotlin-0.2.35\dist\extension.js:2:602530)
at async k.start (c:\Users\accompagnant.vscode\extensions\fwcd.kotlin-0.2.35\dist\extension.js:2:593505)
i have the same problem, any solution?
I think this started happening for me the July 2024 (1.92) vscode update.
This is could be because of https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2 exactly in https://github.com/fwcd/vscode-kotlin/blob/a2b912de4fa9139eacd976bc0b22907105b83e4a/src/languageSetup.ts#L250
@fwcd Looks like the vscode team opened an issue about this change:
https://github.com/fwcd/vscode-kotlin/issues/153
This is could be because of https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2 exactly in
https://github.com/fwcd/vscode-kotlin/blob/a2b912de4fa9139eacd976bc0b22907105b83e4a/src/languageSetup.ts#L250
Is that languageSetup.ts located in extension's source files? If I understand right, we need to add "shell : true" to that method, so it works correctly, but I have a huge trouble with finding that file
im not saying editing the extension file is impossible... but i think it would be easier to just fork it or find a fork with the fix then copy the js file from the build to your extension folder since the js is jumbbled, altho if you are stubborn enough like me or cant wait and want to change it now... you can do it too, like this:
if you are in windows you can go to (in linux its probably ~/.vscode but cmiiw)
%USERPROFILE%.vscode\extensions\fwcd.kotlin-0.2.35\dist
then look for
,["--tcpClientPort",t]
// change it to
,["--tcpClientPort",t],{shell:true}
but not only this you will have to add c.shell=true where where ever you found .spawn( like so
and i would suggest using any lightweight text editor like vim nano or notepad (i tried using vscode and it lagged pretty hard for every letter i pressed, tbf i had js extension so maybe disable it ? idk didnt try)
i have the same problem for 2 days
Here is the patched file PATCH.zip
%USERPROFILE%.vscode\extensions\fwcd.kotlin-0.2.35\dist this will replace the js file
%USERPROFILE%.vscode\extensions\fwcd.kotlin-0.2.35\dist this will replace the js file
Thank 😊
@A-Boring-Square You are the real GOAT
Your welcome what's funny is I don't even use this extension anymore
Here is the patched file PATCH.zip
Why not make a pull request and link it here if you know how to fix it?
It works, by the way.
@fwcd should already fixes it then
The patch doesnt work anymore
The patch still works. I just added it today and it fixed it ... although I got "null" for all references when trying to hover.. Any plans for @fwcd to include a fix in the main?
I don't think the repo owner checks issues.
I don't think the repo owner checks issues.
what do we do then?
im not sure what you mean by "null" when trying to hover ? or is it me using the older version of vscode ?
this is my vscode about section: Version: 1.95.3 (user setup) Commit: f1a4fb101478ce6ec82fe9627c43efbf9e98c813 Electron: 32.2.1 ElectronBuildId: 10427718 Node.js: 20.18.0 V8: 12.8.374.38-electron.0
@onixldlc thanks for your tips :)
since you seem to understand what to edit, what do we need to change there in the dist for spawned processes to work on paths where there's spaces. for example this will always be the case on VS Code Insiders, as the cached data (language server) is in %APPDATA%\Code - Insiders\User\globalStorage\fwcd.kotlin
anyway i fixed it
here's the dist files, and the vsix if you're lazy :
dist.zip
kotlin-0.3.0-vsix.zip
@fwcd it's really nice that you fixed the issue, however note that the extension still won't work when the path to the language server contains spaces (ex when using VS Code Insiders)
perhaps check what I did here, I don't know if it's the best way to fix it but at least it works