lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
dharrigan 2021-06-23T12:40:16.181900Z

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

dharrigan 2021-06-23T12:40:19.182100Z

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

dharrigan 2021-06-23T12:40:41.182500Z

That's on the debug of CocCommand workspace.showOutput

dharrigan 2021-06-23T12:40:54.182700Z

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

dharrigan 2021-06-23T12:41:18.183Z

Shall I log an issue on github?

dharrigan 2021-06-23T12:41:47.183200Z

(clojure-lsp fails to startup)

rafaeldelboni 2021-06-24T12:11:57.194600Z

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)

rafaeldelboni 2021-06-24T12:13:15.194900Z

My versions:

clojure-lsp 2021.06.24-01.20.01
clj-kondo 2021.06.18

dharrigan 2021-06-24T12:20:37.195400Z

I pushed up a fix for this error

dharrigan 2021-06-24T12:20:39.195600Z

it's on a PR

dharrigan 2021-06-24T12:20:57.195800Z

<https://github.com/clojure-lsp/clojure-lsp/pull/452>

dharrigan 2021-06-24T12:21:15.196Z

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

dharrigan 2021-06-24T12:21:23.196200Z

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

dharrigan 2021-06-24T12:21:28.196400Z

After that it works grand for me

rafaeldelboni 2021-06-24T12:22:31.196600Z

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?

dharrigan 2021-06-24T12:31:59.196900Z

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

dharrigan 2021-06-24T12:32:51.197100Z

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

dharrigan 2021-06-24T12:33:08.197300Z

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

dharrigan 2021-06-24T12:33:55.197600Z

it only builds with java 8 btw

dharrigan 2021-06-24T12:34:21.197800Z

sudo archlinux-java set java-8-openjdk temporarily

dharrigan 2021-06-24T12:34:24.198Z

(I'm on 16)

rafaeldelboni 2021-06-24T12:37:04.198200Z

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

rafaeldelboni 2021-06-24T12:37:32.198400Z

I'm running make prod-native now

dharrigan 2021-06-24T12:42:01.198600Z

For me, it falls over unless I build with java 8 πŸ™‚

rafaeldelboni 2021-06-24T12:46:11.198800Z

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

rafaeldelboni 2021-06-24T12:46:41.199Z

compiling bugfix/issue-451 now

rafaeldelboni 2021-06-24T12:52:05.199300Z

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

dharrigan 2021-06-24T12:52:05.199500Z

πŸ™‚

dharrigan 2021-06-24T12:52:07.199700Z

w00t w00t

dharrigan 2021-06-24T12:52:28.199900Z

:partywombat:

ericdallo 2021-06-24T13:21:11.200100Z

My bad, I missed that one :(

ericdallo 2021-06-24T14:44:58.200500Z

Released the fix!

dharrigan 2021-06-24T14:50:11.200700Z

And Arch has been updated to include said fix πŸ˜„

dharrigan 2021-06-24T14:50:20.200900Z

@rafaeldelboni

rafaeldelboni 2021-06-24T14:50:37.201100Z

:thanks3:

2021-06-23T13:16:53.184400Z

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?) ?

ericdallo 2021-06-23T13:19:13.184500Z

Yes, please, I'll take a look

ericdallo 2021-06-23T13:20:02.184700Z

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

ericdallo 2021-06-23T13:20:29.184900Z

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

ericdallo 2021-06-23T13:20:38.185100Z

Are you using emacs?

ericdallo 2021-06-23T13:21:04.185300Z

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

pez 2021-06-23T13:46:49.185500Z

It’s Calva πŸ˜ƒ And something needed in Calva itself.

ericdallo 2021-06-23T13:47:21.185700Z

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

ericdallo 2021-06-23T13:47:29.185900Z

Calva server info or something

pez 2021-06-23T13:51:56.186100Z

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 @brandon.ringe will just tell me where to look, haha.)

ericdallo 2021-06-23T13:53:02.186300Z

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

dharrigan 2021-06-23T14:02:15.186700Z

np

ericdallo 2021-06-23T14:02:48.186900Z

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

dharrigan 2021-06-23T14:05:55.187100Z

github issue created πŸ™‚

ericdallo 2021-06-23T14:06:47.187300Z

thanks, I found the problem on both lsp-mode and clojure-lsp, I'll fix both πŸ™‚

pez 2021-06-23T14:18:48.187500Z

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

ericdallo 2021-06-23T14:20:37.187700Z

Oh, got it, it's the same issue we talked indeed, I thought @pratikgandhi1997 was with issues on Calva, but it's seems a developer issue πŸ˜…

1πŸ‘
ericdallo 2021-06-23T14:21:11.187900Z

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

ericdallo 2021-06-23T14:21:24.188100Z

like server-info-raw or something

pez 2021-06-23T14:23:59.188300Z

That would be awesome.

dharrigan 2021-06-23T15:23:06.188600Z

Thank you πŸ™‚

ericdallo 2021-06-23T20:51:02.188900Z

@pratikgandhi1997 check https://github.com/clojure-lsp/clojure-lsp/issues/450

3🀘