vscode-kotlin icon indicating copy to clipboard operation
vscode-kotlin copied to clipboard

Kotlin Language Client client: couldn't create connection to server.

Open Emandac opened this issue 1 year ago • 19 comments

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) Screenshot (1584) Screenshot (1585)

Emandac avatar Aug 01 '24 19:08 Emandac

i have the same problem, any solution?

saintfts avatar Aug 02 '24 16:08 saintfts

I think this started happening for me the July 2024 (1.92) vscode update.

othercorey avatar Aug 02 '24 21:08 othercorey

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

willnode avatar Aug 03 '24 10:08 willnode

@fwcd Looks like the vscode team opened an issue about this change:

https://github.com/fwcd/vscode-kotlin/issues/153

othercorey avatar Aug 03 '24 19:08 othercorey

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

projectGuy7 avatar Aug 13 '24 13:08 projectGuy7

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}

image

but not only this you will have to add c.shell=true where where ever you found .spawn( like so image 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)

onixldlc avatar Aug 15 '24 06:08 onixldlc

i have the same problem for 2 days

TheNotoriousF14 avatar Aug 15 '24 19:08 TheNotoriousF14

Here is the patched file PATCH.zip

A-Boring-Square avatar Aug 20 '24 22:08 A-Boring-Square

Here is the patched file PATCH.zip

Where do I put the extracted files ?

Emandac avatar Aug 20 '24 22:08 Emandac

%USERPROFILE%.vscode\extensions\fwcd.kotlin-0.2.35\dist this will replace the js file

A-Boring-Square avatar Aug 21 '24 02:08 A-Boring-Square

%USERPROFILE%.vscode\extensions\fwcd.kotlin-0.2.35\dist this will replace the js file

Thank 😊

Emandac avatar Aug 21 '24 09:08 Emandac

@A-Boring-Square You are the real GOAT

RowdyRushya avatar Aug 29 '24 22:08 RowdyRushya

Your welcome what's funny is I don't even use this extension anymore

A-Boring-Square avatar Aug 30 '24 12:08 A-Boring-Square

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.

halotroop2288 avatar Sep 07 '24 00:09 halotroop2288

@fwcd should already fixes it then

willnode avatar Sep 07 '24 00:09 willnode

The patch doesnt work anymore

emilianpr avatar Oct 07 '24 07:10 emilianpr

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?

TheErondu avatar Oct 13 '24 06:10 TheErondu

I don't think the repo owner checks issues.

othercorey avatar Oct 13 '24 06:10 othercorey

I don't think the repo owner checks issues.

what do we do then?

TheErondu avatar Oct 13 '24 06:10 TheErondu

image 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 avatar Nov 18 '24 04:11 onixldlc

@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

EDM115 avatar Nov 22 '24 14:11 EDM115

anyway i fixed it here's the dist files, and the vsix if you're lazy :
dist.zip
kotlin-0.3.0-vsix.zip

EDM115 avatar Nov 25 '24 08:11 EDM115

@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

EDM115 avatar Dec 08 '24 10:12 EDM115