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

Go-to-definition crashes when jar has plus sign in name #326

Open
clarfonthey opened this issue Feb 5, 2022 · 1 comment
Open

Go-to-definition crashes when jar has plus sign in name #326

clarfonthey opened this issue Feb 5, 2022 · 1 comment
Labels
bug Something isn't working dependency resolution Related to the project dependency/standard library resolver

Comments

@clarfonthey
Copy link

Somewhere along the line, the plus in the file:// URL is converted to a space, causing a crash by a NoSuchFileException.

I found this while writing a minecraft mod; I made a (mostly minimal) git repo to replicate the error: https://github.com/clarfonthey/kt-lsp-bug-repro

The following is the output I get from kak-lsp while attempting to go-to-definition for one of the sponge classes in CrashReport_noopMixin.kt. I additionally have the environment variable CLASSPATH=/usr/share/kotlin/lib/*.jar set.

*** This is the debug buffer, where debug info will be written ***
kak-lsp: config-change detected: 
kak-lsp: log: main      Adding script definitions [ScriptTemplateWithArgs]
kak-lsp: log: main      Kotlin Language Server: Version 1.2.0
kak-lsp: log: main      Connected to client
kak-lsp: log: async0    Adding workspace folder null
kak-lsp: log: async0    Adding .../minecraft-test/build.gradle.kts, .../minecraft-test/settings.gradle.kts, .../mixins/CrashReport_noopMixin.kt under /home/ltdk/minecraft-test to source path
kak-lsp: log: async0    Searching for dependencies and Java sources in workspace root /home/ltdk/minecraft-test
kak-lsp: log: async0    Resolving dependencies for 'minecraft-test' through Gradle's CLI using tasks [kotlinLSPProjectDeps]...
kak-lsp: log: async0    Found gradle at /usr/bin/gradle
kak-lsp: log: async0    Successfully resolved dependencies for 'minecraft-test' using Gradle
kak-lsp: log: async0    Resolving dependencies for 'minecraft-test' through Gradle's CLI using tasks [kotlinLSPProjectDeps]...
kak-lsp: log: async0    Found gradle at /usr/bin/gradle
kak-lsp: log: async0    Successfully resolved dependencies for 'minecraft-test' using Gradle
kak-lsp: log: async0    Adding 112 files to class path
kak-lsp: log: async0    Update build script path
kak-lsp: log: async0    Resolving dependencies for 'minecraft-test' through Gradle's CLI using tasks [kotlinLSPKotlinDSLDeps]...
kak-lsp: log: async0    Found gradle at /usr/bin/gradle
kak-lsp: language server is not initialized, parking request
kak-lsp: log: async0    Successfully resolved build script dependencies for 'minecraft-test' using Gradle
kak-lsp: log: async0    Adding 495 files to build script class path
kak-lsp: log: async0    Reinstantiating compiler
kak-lsp: log: async0    Adding script definitions [ScriptTemplateWithArgs]
kak-lsp: log: async0    Configuring Kotlin DSL script templates...
kak-lsp: log: async0    Adding script definitions [ScriptTemplateWithArgs, KotlinInitScript, KotlinSettingsScript, KotlinBuildScript]
kak-lsp: log: debounce0 Linting .../mixins/CrashReport_noopMixin.kt
kak-lsp: log: async2    Go-to-definition at .../mixins/CrashReport_noopMixin.kt 4:36
kak-lsp: log: async3    Updating symbol index...
kak-lsp: log: debounce0 Linting 0 files
kak-lsp: log: async2    Re-parsing CrashReport_noopMixin.kt 0:1-14:1
kak-lsp: log: async2    Hovering DOT_QUALIFIED_EXPRESSION
kak-lsp: log: async2    Found declaration descriptor Lazy Java class org.spongepowered.asm.mixin.Mixin
kak-lsp: log: async2    Finding contents of kls:file:///home/ltdk/.gradle/caches/modules-2/files-2.1/net.fabricmc/sponge-mixin/0.10.7%20mixin.0.8.4/7a4ca9d54d9ae564dea0363d668036a8420ed9b8/sponge-mixin-0.10.7%20mixin.0.8.4.jar!/org/spongepowered/asm/mixin/Mixin.class
kak-lsp: log: async2    Finished in 1389 ms
kak-lsp: log: async2    Internal error: java.nio.file.NoSuchFileException: /home/ltdk/.gradle/caches/modules-2/files-2.1/net.fabricmc/sponge-mixin/0.10.7 mixin.0.8.4/7a4ca9d54d9ae564dea0363d668036a8420ed9b8/sponge-mixin-0.10.7 mixin.0.8.4.jar
kak-lsp: log: java.util.concurrent.CompletionException: java.nio.file.NoSuchFileException: /home/ltdk/.gradle/caches/modules-2/files-2.1/net.fabricmc/sponge-mixin/0.10.7 mixin.0.8.4/7a4ca9d54d9ae564dea0363d668036a8420ed9b8/sponge-mixin-0.10.7 mixin.0.8.4.jar
kak-lsp: log: 	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
kak-lsp: log: 	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
kak-lsp: log: 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770)
kak-lsp: log: 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
kak-lsp: log: 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
kak-lsp: log: 	at java.base/java.lang.Thread.run(Thread.java:833)
kak-lsp: log: Caused by: java.nio.file.NoSuchFileException: /home/ltdk/.gradle/caches/modules-2/files-2.1/net.fabricmc/sponge-mixin/0.10.7 mixin.0.8.4/7a4ca9d54d9ae564dea0363d668036a8420ed9b8/sponge-mixin-0.10.7 mixin.0.8.4.jar
kak-lsp: log: 	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
kak-lsp: log: 	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
kak-lsp: log: 	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
kak-lsp: log: 	at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
kak-lsp: log: 	at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:149)
kak-lsp: log: 	at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
kak-lsp: log: 	at java.base/java.nio.file.Files.readAttributes(Files.java:1851)
kak-lsp: log: 	at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1264)
kak-lsp: log: 	at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:709)
kak-lsp: log: 	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:243)
kak-lsp: log: 	at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:172)
kak-lsp: log: 	at java.base/java.util.jar.JarFile.<init>(JarFile.java:347)
kak-lsp: log: 	at java.base/sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:103)
kak-lsp: log: 	at java.base/sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:72)
kak-lsp: log: 	at java.base/sun.net.www.protocol.jar.JarFileFactory.getOrCreate(JarFileFactory.java:106)
kak-lsp: log: 	at java.base/sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:132)
kak-lsp: log: 	at java.base/sun.net.www.protocol.jar.JarURLConnection.getJarEntry(JarURLConnection.java:97)
kak-lsp: log: 	at org.javacs.kt.externalsources.KlsURI.extractToTemporaryFile(KlsURI.kt:104)
kak-lsp: log: 	at org.javacs.kt.externalsources.JarClassContentProvider.tryReadContentOf(JarClassContentProvider.kt:60)
kak-lsp: log: 	at org.javacs.kt.externalsources.JarClassContentProvider.contentOf(JarClassContentProvider.kt:42)
kak-lsp: log: 	at org.javacs.kt.definition.GoToDefinitionKt.goToDefinition(GoToDefinition.kt:48)
kak-lsp: log: 	at org.javacs.kt.KotlinTextDocumentService$definition$1.invoke(KotlinTextDocumentService.kt:129)
kak-lsp: log: 	at org.javacs.kt.KotlinTextDocumentService$definition$1.invoke(KotlinTextDocumentService.kt:124)
kak-lsp: log: 	at org.javacs.kt.util.AsyncExecutor.compute$lambda-2(AsyncExecutor.kt:19)
kak-lsp: log: 	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
kak-lsp: log: 	... 3 more
kak-lsp: kotlin language server error: 'Internal error.'

Focusing on the specific crash:

kak-lsp: log: async2    Internal error: java.nio.file.NoSuchFileException: /home/ltdk/.gradle/caches/modules-2/files-2.1/net.fabricmc/sponge-mixin/0.10.7 mixin.0.8.4/7a4ca9d54d9ae564dea0363d668036a8420ed9b8/sponge-mixin-0.10.7 mixin.0.8.4.jar

If you check out the file it's trying to access, you'll notice that the issue is it converting a plus sign to a space, which normally should only be done in query strings:

-.gradle/caches/modules-2/files-2.1/net.fabricmc/sponge-mixin/0.10.7 mixin.0.8.4/7a4ca9d54d9ae564dea0363d668036a8420ed9b8/sponge-mixin-0.10.7 mixin.0.8.4.jar
+.gradle/caches/modules-2/files-2.1/net.fabricmc/sponge-mixin/0.10.7+mixin.0.8.4/7a4ca9d54d9ae564dea0363d668036a8420ed9b8/sponge-mixin-0.10.7+mixin.0.8.4.jar

Not 100% sure what's happening here, but if you run gradle build by itself, it passes, meaning that the paths definitely are working in gradle internally.

@fwcd fwcd added bug Something isn't working dependency resolution Related to the project dependency/standard library resolver labels Feb 6, 2022
@theoparis
Copy link

Unfortunately this bug is still an issue and it is preventing from using this server instead of using Intellij for developing minecraft mods in Kotlin 😕
Has anyone found a fix that can be applied via a git checkout locally?

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