Fork me on GitHub
#lsp
<
2021-06-23
>
dharrigan12:06:16

getting an error when I startup clojure-lsp (looks like a graalvm error, reflection stuff)

dharrigan12:06:19

Jun 23, 2021 1:38:49 PM org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireError
SEVERE: Unable to invoke no-args constructor for class org.eclipse.lsp4j.CodeLensWorkspaceCapabilities. Registering an InstanceCreator with Gson for this type may fix this problem.
java.lang.RuntimeException: Unable to invoke no-args constructor for class org.eclipse.lsp4j.CodeLensWorkspaceCapabilities. Registering an InstanceCreator with Gson for this type may fix this problem.
	at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:228)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:212)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
	at com.google.gson.Gson.fromJson(Gson.java:932)
	at org.eclipse.lsp4j.adapters.InitializeParamsTypeAdapter.readCapabilities(InitializeParamsTypeAdapter.java:151)
	at org.eclipse.lsp4j.adapters.InitializeParamsTypeAdapter.read(InitializeParamsTypeAdapter.java:109)
	at org.eclipse.lsp4j.adapters.InitializeParamsTypeAdapter.read(InitializeParamsTypeAdapter.java:34)
	at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)
	at com.google.gson.Gson.fromJson(Gson.java:932)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.fromJson(MessageTypeAdapter.java:329)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.parseParams(MessageTypeAdapter.java:249)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:119)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:55)
	at com.google.gson.Gson.fromJson(Gson.java:932)
	at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:119)
	at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:114)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:193)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.lang.Thread.run(Thread.java:829)
	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.reflect.InvocationTargetException
	at java.lang.reflect.Method.invoke(Method.java:566)
	at com.google.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:50)
	at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:225)
	... 28 more
Caused by: java.lang.IllegalArgumentException: Class org.eclipse.lsp4j.CodeLensWorkspaceCapabilities is instantiated reflectively but was never registered. Register the class by using org.graalvm.nativeimage.hosted.RuntimeReflection
	at com.oracle.svm.core.graal.snippets.SubstrateAllocationSnippets.hubErrorStub(SubstrateAllocationSnippets.java:261)
	at sun.misc.Unsafe.allocateInstance(Unsafe.java:840)
	... 31 more

dharrigan12:06:41

That's on the debug of CocCommand workspace.showOutput

dharrigan12:06:54

❯ clojure-lsp --version
clojure-lsp 2021.06.21-14.30.54
clj-kondo 2021.06.18

dharrigan12:06:18

Shall I log an issue on github?

dharrigan12:06:47

(clojure-lsp fails to startup)

ericdallo13:06:13

Yes, please, I'll take a look

ericdallo14:06:48

I didn't catch that because it seems lsp-mode (emacs) doesn't send that for some reason

dharrigan14:06:55

github issue created 🙂

ericdallo14:06:47

thanks, I found the problem on both lsp-mode and clojure-lsp, I'll fix both 🙂

dharrigan15:06:06

Thank you 🙂

rafaeldelboni00:06:00

I just jumped to nvim 0.5.0 and I was investigating if this was related, thanks I didn't spent much time before searching here 😁

ericdallo01:06:46

Yeah, I made sure this doesn't happen only for vim anymore fixing it on emacs as well, also I'll release tomorrow morning the clojure-lsp fix @UMMMKKADU

rafaeldelboni01:06:57

Oh I will wait then, I was looking to install graalvm in my machine right now to get the patched bin

rafaeldelboni01:06:03

I just thought that would be cool to have a nightly release in some sort like https://github.com/neovim/neovim/releases/tag/nightly

ericdallo01:06:48

Usually we don't have quick fixes like this and we already release pretty fast, but it's a idea indeed

ericdallo01:06:41

@UMMMKKADU Actually, I'll release it right now as my lsp-mode fix will bring more issues like this until tomorrow

rafaeldelboni12:06:57

Still getting an error, is quite similar to the one dharrigan posted, but is for a different class:

org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireError
SEVERE: Unable to invoke no-args constructor for class org.eclipse.lsp4j.LinkedEditingRangeCapabilities. Registering an InstanceCreator with Gson for this type may fix this problem.
java.lang.RuntimeException: Unable to invoke no-args constructor for class org.eclipse.lsp4j.LinkedEditingRangeCapabilities. Registering an InstanceCreator with Gson for this type may fix this problem.
	at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:228)

rafaeldelboni12:06:15

My versions:

clojure-lsp 2021.06.24-01.20.01
clj-kondo 2021.06.18

dharrigan12:06:37

I pushed up a fix for this error

dharrigan12:06:39

it's on a PR

dharrigan12:06:15

Waiting for it to be reviewed and merged (if appropriate)

dharrigan12:06:23

In the meantime, you can apply the branch yourself and build locally?

dharrigan12:06:28

After that it works grand for me

rafaeldelboni12:06:31

Yeah I will make the setup in my machine, you use arch linux right, do I need https://aur.archlinux.org/packages/native-image-jdk11-bin/ and there is any other deps?

dharrigan12:06:59

Nope, although I downloaded graalvm directly and put it on my $PATH

dharrigan12:06:51

You'll need to build the classes first, i.e., clj -X:javac then ./graalvm/native-unix-compile.sh

dharrigan12:06:08

then I put the clojure-lsp binary in my $PATH to replace the system installed one.

dharrigan12:06:55

it only builds with java 8 btw

dharrigan12:06:21

sudo archlinux-java set java-8-openjdk temporarily

rafaeldelboni12:06:04

woah haha, I did the make prod-bin with java-11-openjdk

rafaeldelboni12:06:32

I'm running make prod-native now

dharrigan12:06:01

For me, it falls over unless I build with java 8 🙂

rafaeldelboni12:06:11

It compiled fine, but I'm quite dumb and I compiled the master branch of your fork :kill-me:

rafaeldelboni12:06:41

compiling bugfix/issue-451 now

rafaeldelboni12:06:05

Yeap can confirm @U11EL3P9U's branch is working fine for me

ericdallo13:06:11

My bad, I missed that one :(

ericdallo14:06:58

Released the fix!

dharrigan14:06:11

And Arch has been updated to include said fix 😄

ericdallo00:03:34

Kind of late, but we do have now #clojure-lsp-builds @UMMMKKADU :)

❤️ 1
🆒 1
Pratik13:06:53

Is there a way to get source-paths in clojure-lsp ? whether it has been defined in .lsp/config or anywhere else(if that’s possible?) ?

ericdallo13:06:02

if your project is not a deps.edn, it'll show on the server-info command

ericdallo13:06:29

I need to make it show on server-info for deps.edn projects as well

ericdallo13:06:38

Are you using emacs?

ericdallo13:06:04

If so, lsp-clojure-server-info should return that

pez13:06:49

It’s Calva 😃 And something needed in Calva itself.

ericdallo13:06:21

You can get the server-info via Calva as well, I know there is a command

ericdallo13:06:29

Calva server info or something

pez13:06:56

Yeah, but it prints it to the clojure-lsp output channel. We’ve talked about this before. 😃 (And I still haven’t checked it up closer, hoping that @U9A1RLFNV will just tell me where to look, haha.)

ericdallo13:06:02

But isn't that enough? I can see all the necessary info from the output:

pez14:06:48

It’s Calva that needs the info. Not the user.

ericdallo14:06:37

Oh, got it, it's the same issue we talked indeed, I thought @U01PG2LDYV8 was with issues on Calva, but it's seems a developer issue 😅

👍 2
ericdallo14:06:11

Yeah, I think there is no easy way ATM, but I thing I can make that work as a custom command

ericdallo14:06:24

like server-info-raw or something

pez14:06:59

That would be awesome.