-
Notifications
You must be signed in to change notification settings - Fork 228
Language Server appears to be out of sync with command line gradle #126
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
Comments
Actually, an important omission in the previous commentary is that there likely are some problems in the setup of my kotlin project. I have created as a way to learn how kotlin projects work, (mostly) by hand, and with the objective of supporting multi-project builds [1]. Maybe I have done something that is confusing KLS. My file structure is as follows (files that were generated by gradle are marked as
All my targets (build, test, etc) work from the gradle CLI. I will try to clean up the project and put it on a stand alone GitHub project if it helps. [1] https://docs.gradle.org/current/userguide/multi_project_builds.html |
Yet another interesting point: I see a few errors in
And
The second error is related to plain kotlin code, the first I'm not too sure. |
As a control test, I've decided to clone the KotlinQuickStart repo [1] and validate KTS from there. I experience the same problems with the Kotlin DSL. Upon further investigation, it seems the kotlin DSL is actually not yet supported [2], so I will switch off LSP for these files. On the other hand, I do seem to get good error checking on the regular kotlin files. I will try to bring across code from my project and see if I can get it to work... [1]https://github.com/fwcd/KotlinQuickStart |
OK, I've managed to reproduce my problems using the KotlinQuickStart repo. I modified the code as follows:
I had to add
These are all of the vertx imports. It seems I need to "resync" KTS after gradle downloaded the new jars? |
OK, I now realised that by restarting my workspace I can get KLS to pick up the dependencies (
For good measure, I installed VS code just to see if this was an emacs problem but it also complains about the same error. |
OK right so this ticket is quite long and rambling-y, so I think its worth summarising my findings:
Which means that the only real problem I have is this one:
To avoid confusion, I think I will close this ticket and open a new one focused only on this problem. |
A ticket for this already exists [1], so I'll move the discussion there. [1] #72 |
Thanks for investigating and providing such a detailed description of the issue! I have to admit that I haven't got around to test the compiled KLS on Java 11 projects yet, though this will definitely be part of #109, since KLS should always support its own codebase. |
Hi Kotlin Language Server developers,
Many thanks for a great project. I have been trying to set it up against emacs, but I must be doing something very silly because I get errors with KLS that I do not see when I manually run gradle. Let me first explain my setup. I am using Debian testing on x64 and I installed kotlin using SDK Man [0]. I have tried two distinct setups though, sadly, with more or less the same outcome.
Setup using Java 11
I have read through the many posts detailing how it is not possible to use Java 11 to build KLS - e.g. [1, 2, 3] - but it was still unclear to me if this limitation also applied to building user projects or only to building KLS itself [4]. So I started first by installing openjdk-11 and using the binaries supplied on GitHub [5]. Though there is no out of the box support on emacs for KLS [6], thanks to the help of the emacs lsp community, I managed to get emacs to start KLS and report errors on my kotlin code.
The weird thing was that it all worked well at first, but as I started to add more dependencies and change the project files, I started to see errors in KLS that I do not see in gradle. In particular, I see:
However, my gradle file states:
In addition, my kts (gradle Kotlin script files) are riddled with errors:
The first error stems from this line:
To the untrained eye, it seems like the gradle kotlin DSL files are just not being picked up correctly.
Setup using Java 8
I then decided to investigate two questions:
For this I relied on openjdk-8, but sadly it is not (entirely) available on Debian testing. The missing packages were downloaded manually from their FTP server [7]:
Once installed I selected the java version via alternatives:
And set it to Java 8. I confirmed that my binaries were running from Java 8, as well as my local build using gradle. I then git cloned KLS and built it as per my understanding of the instructions:
It all worked fine. I then installed the resulting binaries, restarted emacs and picked up the new KLS. However, I am getting exactly the same errors as I had before, as per section above.
Conclusions
So it seems to me my problems are actually not related to the java version, but to my project. The weird thing is that when I run
gradle build
(or via the gradle wrapper) it all works. So I'm trying to figure out what KLS is doing differently. Can you point out to mistakes I have done on my setup, or if nothing obvious can be spotted, on ways to get more debug information about what KLS is doing?Thanks very much for all your help.
Marco
[0] https://kotlinlang.org/docs/tutorials/command-line.html
[1] #125
[2] #108
[3] #114
[4] #124
[5] https://github.com/fwcd/KotlinLanguageServer/releases/tag/0.1.13
[6] emacs-lsp/lsp-mode#900
[7] http://ftp.debian.org/debian/pool/main/o/openjdk-8/
The text was updated successfully, but these errors were encountered: