fwcd / kotlin-language-server

Kotlin code completion, diagnostics and more for any editor/IDE using the Language Server Protocol
MIT License
1.65k stars 207 forks source link

Ensure that Kotlin Script Runtime is on classpath in non-Gradle/Kotlin DSL projects #159

Open fwcd opened 5 years ago

fwcd commented 5 years ago

grafik

ghost commented 4 years ago

@fwcd Hoping for this issue to be fixed ASAP...

kotlin-script

MaienM commented 4 years ago

It's not ideal, but adding the folder containing this jar to the CLASSPATH when running the server does seem to work for me.

CLASSPATH="/usr/share/kotlin/lib" kotlin-language-server

rmencattini commented 4 years ago

@MaienM is your solution compatible with only visual studio code extension? Because I cannot see this option in the extensions settings. Did I miss something? Thx

It's not ideal, but adding the folder containing this jar to the CLASSPATH when running the server does seem to work for me.

CLASSPATH="/usr/share/kotlin/lib" kotlin-language-server

vaclavbenes commented 2 years ago

Hi, Did someone try that on MacOs ? I have different path or should I call custom kotlin-language-server ? @fwcd

phinney commented 2 years ago

I had this problem and it looked to me that I had added the proper dependencies. When I looked at the Gradle window, I noticed that the dependencies that I had specified in the offending modules build.gradle.kts file were not the same dependencies that the Gradle window was showing me for that same module. Eventually what got me on the path to solving this issue was to delete the gradle cache. In windows, it's located in your user directory .gradle/cache. Well, that didn't immediately solve the problem! I think I had to re-synch gradle (an option in the Gradle window) and then I needed to restart the IDE (which I'm using is IntellJ Idea 2021.1). There's also one more thing, in my dependency implementation I had "org.gradle.kotlin:gradle-kotlin-dsl-plugins:2.2.0". I had to change it to "org.gradle.kotlin:gradle-kotlin-dsl-plugins:2.1.4". The gradle version I'm using is 7.1. For some reason, unknown to me, the Gradle window kept showing me that I was using 2.1.4, even though I was consistently specifiying 2.2.0 in the root build.gradle.kts, in my buildSrc build.grade.kts, and in the offending module's build.gradle.kts. I think that's because I'm using gradle version 7.1. By doing these things, in an order that I don't precisely remember, the problem just disappear. I had done a search in File for where the 2.1.4 was being specified and I found some internal file (whose name I don't remember) is where I saw where I think the dependency on 2.1.4 comes from. I'm convenience that clearing the gradle cache was a big part for me getting around this problem together with providing the right consistent dependencies for you version of gradle, but I can't claim this for certainty. Hopefully the information I'm providing proves to be useful in how to approach the solution to this problem.

testersen commented 1 year ago

Still experiencing this issue.

orvitpng commented 1 year ago

I am also still experiencing this. The issue has been open since 2019, how long until this gets fixed?

themkat commented 1 year ago

I am also still experiencing this. The issue has been open since 2019, how long until this gets fixed?

There are almost no contributors on this project, so impossible to tell. Remember that the few of us who contribute do so in our spare time after many hours of work, so we don't have time for everything (and therefore have to prioritize what we deem to be the most important, or what we want the most). You are off course free to try to contribute a fix 🙂

I think this issue (the original NON-Gradle/Kotlin DSL one) has not been prioritized for several reasons, most importantly that it is very easy to work around. One way is adding an environment variable to a custom path like above. The way I prefer is to use something like KScripts IDEA temporary project launch to set up a temporary Gradle project. This will make sure everything is in the classpath for you. Simply set KSCRIPT_COMMAND_IDEA to something other than IntelliJ. For me that is emacsclient -n, like I have written about in more detail on my blog.

The issue with build.gradle.kts and other Gradle related files (like mentioned in the second comment above) is fixed (with some minor open issues).