Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension fails on Ubuntu devcontainer - couldn't create connection to server. #564

Open
spaceunifyfifty opened this issue Mar 3, 2024 · 3 comments
Labels
bug Something isn't working dependency resolution Related to the project dependency/standard library resolver

Comments

@spaceunifyfifty
Copy link

I am attempting to write Kotlin code within GitHub Codespaces, which are just remote ubuntu virtual machines viewed through the web client for vscode. I have tried doing this both for an empty folder structure containing only a Main.kt hello world with no Gradle/Maven, and for a pre-existing Gradle project that works on my local machine that I push up to GitHub and create the codespace from; both result in the Kotlin extension giving the error

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

resulting in no IDE hints / Intellisense.

When I go to the output, the following snippets seem most notable to me

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Caused by: org.javacs.kt.util.KotlinLSException: No repositories found at $MAVEN_REPOSITORY, $MAVEN_HOME, $M2_HOME or $HOME/.m2` seems most relevant.
[Error] Kotlin Language Client client: couldn't create connection to server.
  Message: Internal error.
  Code: -32603 

Here is a gist of the full console output.

Has anyone been able to get Kotlin language server in vscode working on a devcontainer / GitHub codespace?

Reproduce steps

  1. Create a new github repository containing an empty README.md
  2. Create new codespace from repository on main branch, with default specs 2-core, 8GB RAM, 32GB.
  3. Confirm that Java is installed
/workspaces/testkotlin (main) $ java --version
openjdk 21.0.2 2024-01-16 LTS
OpenJDK Runtime Environment Microsoft-8905927 (build 21.0.2+13-LTS)
OpenJDK 64-Bit Server VM Microsoft-8905927 (build 21.0.2+13-LTS, mixed mode, sharing)
  1. Install kotlin compiler
/workspaces/testkotlin (main) $ sdk install kotlin

Downloading: kotlin 1.9.22
In progress...
################################################################################################################################################ 100.0%
Installing: kotlin 1.9.22
Done installing!
Setting kotlin 1.9.22 as default.
  1. Install Kotlin extension. Click Ok, Continue on dependency installation prompt
image
  1. Create a Main.kt file
fun main() {
    println("Hello world")
}

Observe error notice
image

@spaceunifyfifty
Copy link
Author

spaceunifyfifty commented Mar 3, 2024

Found this repo https://github.com/alexanderhansen/vscode-remote-try-kotlin, everything works when I create a codespace from it. What is his repo doing right that mine is not?

@fwcd
Copy link
Owner

fwcd commented Mar 8, 2024

Caused by: org.javacs.kt.util.KotlinLSException: No repositories found at $MAVEN_REPOSITORY, $MAVEN_HOME, $M2_HOME or $HOME/.m2` seems most relevant.

looks suspicious, the SLF4J stuff is fine (should probably add a troubleshooting entry on that). We probably should not be throwing an exception if we cannot find a local Maven repository (maybe make it optional instead?):

https://github.com/fwcd/kotlin-language-server/blob/7dd4680017d7f04f621fbb952988a78b7dca581e/shared/src/main/kotlin/org/javacs/kt/classpath/Home.kt#L20C14-L24

Note that support for non-Gradle/Maven projects isn't great yet, mostly because there are so many different ways Kotlin and its standard library could be packaged.

@fwcd fwcd added bug Something isn't working dependency resolution Related to the project dependency/standard library resolver labels Mar 8, 2024
@dmccoystephenson
Copy link

I am also running into this error when attempting to use this plugin inside of a dev container with VSCode. I am using eclipse-temurin:17-jdk-jammy as a base image.

Here is the relevant output from the console:

[Error - 3:09:03 AM] Kotlin Language Client client: couldn't create connection to server.
Message: Internal error.
Code: -32603
java.util.concurrent.CompletionException: java.lang.ExceptionInInitializerError
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.ExceptionInInitializerError
at org.javacs.kt.classpath.BackupClassPathResolverKt.findLocalArtifactDirUsingMaven(BackupClassPathResolver.kt:88)
at org.javacs.kt.classpath.BackupClassPathResolverKt.findLocalArtifact(BackupClassPathResolver.kt:25)
at org.javacs.kt.classpath.BackupClassPathResolverKt.findKotlinStdlib(BackupClassPathResolver.kt:21)
at org.javacs.kt.classpath.WithStdlibResolverKt.wrapWithStdlib(WithStdlibResolver.kt:42)
at org.javacs.kt.classpath.WithStdlibResolverKt.access$wrapWithStdlib(WithStdlibResolver.kt:1)
at org.javacs.kt.classpath.WithStdlibResolver.getBuildScriptClasspath(WithStdlibResolver.kt:10)
at org.javacs.kt.classpath.FirstNonEmptyClassPathResolver.getBuildScriptClasspath(ClassPathResolver.kt:76)
at org.javacs.kt.classpath.CachedClassPathResolver.getBuildScriptClasspath(CachedClassPathResolver.kt:132)
at org.javacs.kt.classpath.ClassPathResolver$DefaultImpls.getBuildScriptClasspathOrEmpty(ClassPathResolver.kt:24)
at org.javacs.kt.classpath.CachedClassPathResolver.getBuildScriptClasspathOrEmpty(CachedClassPathResolver.kt:52)
at org.javacs.kt.CompilerClassPath.refresh(CompilerClassPath.kt:75)
at org.javacs.kt.CompilerClassPath.refresh$default(CompilerClassPath.kt:47)
at org.javacs.kt.CompilerClassPath.addWorkspaceRoot(CompilerClassPath.kt:120)
at org.javacs.kt.KotlinLanguageServer$initialize$1.invoke(KotlinLanguageServer.kt:129)
at org.javacs.kt.KotlinLanguageServer$initialize$1.invoke(KotlinLanguageServer.kt:74)
at org.javacs.kt.util.AsyncExecutor.compute$lambda$2(AsyncExecutor.kt:19)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
... 3 more
Caused by: org.javacs.kt.util.KotlinLSException: No repositories found at $MAVEN_REPOSITORY, $MAVEN_HOME, $M2_HOME or $HOME/.m2
at org.javacs.kt.classpath.HomeKt.(Home.kt:22)
... 20 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependency resolution Related to the project dependency/standard library resolver
Projects
None yet
Development

No branches or pull requests

3 participants