vscode-kotlin
vscode-kotlin copied to clipboard
Language server does not find openjdk installation (sdkman)
Describe the bug When I want open up a kotlin file the language server fails to startup.
No Java runtime present, requesting install.
[Info - 2:44:28 PM] Connection to server got closed. Server will restart
I also get the modal To use the "java" comand-line tool you need to install a JDK.
To Reproduce Steps to reproduce the behavior:
- Open up a *.kt file
Expected behavior The language server succeeds in starting
Extension version
0.2.11
Additional context
I am using sdkman
and have openjdk 11 and kotlin 1.3.72 installed and set to default.
java
is accessible in the path
and JAVA_HOME
is set.
OSX Catalina.
Facing same issue
I am facing the same issue with the amzn release of java, installed with sdkman
using:
java 8.312.07.1-amzn
(set by default for the project directory)
java 11.0.13.8.1-amzn
(attempted with this version as well, manually set via sdkman command)
! Error is Java Language Server requires a JDK 11+ to launch itself. The java.home variable defined in Visual Studio Code settings points to a missing or inaccessible folder (/Users/foobar/.sdkman/candidates/java/11.0.11.9.1-amzn)
I found that a deprecated setting in VSCode settings.json was overriding the preferred setting:
"java.home": "/Users/foobar/.sdkman/candidates/java/11.0.11.9.1-amzn",
...
"java.jdt.ls.java.home": "/Users/foobar/.sdkman/candidates/java/11.0.13.8.1-amzn"
java.home
is deprecated, but for some reason is taking precedence over the newer setting.
I've JAVA_HOME
set up:
$ echo $JAVA_HOME
/home/us-er/.asdf/installs/java/openjdk-17
$ java --version
openjdk 17 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)
$ kotlin -version
Kotlin version 1.8.21-release-380 (JRE 17+35-2724)
But still I see this error:
[Info - 12:57:21 PM] Connection to server got closed. Server will restart.
[Error - 12:57:21 PM] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:57:21 PM] Kotlin Language Client client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
[Error - 12:57:21 PM] Client Kotlin Language Client: connection to server is erroring. Shutting down server.
[Error - 12:57:21 PM] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: startFailed
at k.shutdown (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:598229)
at k.stop (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:597810)
at k.stop (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:756885)
at k.handleConnectionError (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:603773)
at /home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:602600
at /home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:601766
at o.invoke (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:552503)
at n.fire (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:553268)
at /home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:544882
at o.invoke (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:552503)
at n.fire (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:553268)
at g.fireError (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:564502)
at Socket.<anonymous> (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:565288)
at Socket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
[Info - 12:57:21 PM] Connection to server got closed. Server will restart.
[Error - 12:57:21 PM] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:57:21 PM] Kotlin Language Client client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
[Info - 12:57:21 PM] Connection to server got closed. Server will restart.
[Error - 12:57:21 PM] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:57:21 PM] Kotlin Language Client client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:57:21 PM] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:57:21 PM] Client Kotlin Language Client: connection to server is erroring. Shutting down server.
[Error - 12:57:21 PM] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: startFailed
at k.shutdown (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:598229)
at k.stop (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:597810)
at k.stop (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:756885)
at k.handleConnectionError (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:603773)
at /home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:602600
at /home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:601766
at o.invoke (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:552503)
at n.fire (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:553268)
at /home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:544882
at o.invoke (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:552503)
at n.fire (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:553268)
at g.fireError (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:564502)
at Socket.<anonymous> (/home/us-er/.vscode/extensions/fwcd.kotlin-0.2.31/dist/extension.js:2:565288)
at Socket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
[Info - 12:57:21 PM] Connection to server got closed. Server will restart.
[Error - 12:57:21 PM] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:57:21 PM] Kotlin Language Client client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:57:21 PM] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
[Error - 12:57:21 PM] The Kotlin Language Client server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 12:57:21 PM] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:57:21 PM] Kotlin Language Client client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 12:57:21 PM] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
Not sure if @fwcd's https://github.com/fwcd/vscode-kotlin/commit/591771f2137f45a13e24db52c0aca05a2d04c335 has to do something with it.
This seems like a VSCode issue rather than asdf/rtx
. Ref: https://github.com/microsoft/vscode/issues/187955