rossabaker / lsp-scala

Scala support for lsp-mode using metals
GNU General Public License v3.0
49 stars 6 forks source link

Not able to run "lsp-scala-build-import" #13

Open ArulselvanMadhavan opened 5 years ago

ArulselvanMadhavan commented 5 years ago

Hi @rossabaker,

Thanks for this package. I followed the instructions in here - https://scalameta.org/metals/docs/editors/emacs.html and also went through the README.

However, I am not able to get this package to work for me. I am unable to figure out what I am doing wrong.

Packages

# emacs package versions
lsp-scala - 5.0
lsp-ui - 0.0.1

# java -version
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
GraalVM 1.0.0-rc5 (build 25.71-b01-internal-jvmci-0.46, mixed mode)

When I open *.scala, I get the message time:initialize 0.12s followed by metals server started at 127.0.0.1:<port> - I checked the metals LSP server is started and running.

I didn't get any prompt to run build-import automatically. So, I ran lsp-scala-build-import and got the message Skipping build import, no checksum

Any suggestions on how to get past this error would be of great help.

rossabaker commented 5 years ago

It looks like you're running GraalVM. Does this happen on a non-Graal project? I don't know why that would make a difference, but it's the thing that sticks out to me as being weird in the above.

olafurpg commented 5 years ago

The problem could be that the detected rootUri (workspace directory) does not point to an sbt build. @ArulselvanMadhavan can look a .metals directory a parent /child directory of your intended build root directory?

rossabaker commented 5 years ago

That was my first guess, but I get the prompt opening a *.scala in directories with no sbt build anywhere in the hierarchy.

ArulselvanMadhavan commented 5 years ago

@rossabaker

I tried lsp-scala in another machine that didn't have Graal installed. I got the prompt to "import build" and it seemed to run and finish successfully. However, I am not able to get the compilation errors in my buffer. When I look at the .metals/metals.log file, I see this.

Dec 20, 2018 8:02:29 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleNotification
WARNING: Notification threw an exception: {
  "jsonrpc": "2.0",
  "method": "workspace/didChangeConfiguration",
  "params": {
    "settings": {}
  }
}
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
    at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:192)
    at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
    at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:99)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
    ... 11 more
Caused by: java.lang.ClassCastException: com.google.gson.JsonNull cannot be cast to com.google.gson.JsonObject
    at com.google.gson.JsonObject.getAsJsonObject(JsonObject.java:191)
    at scala.meta.internal.metals.UserConfiguration$.fromJson(UserConfiguration.scala:47)
    at scala.meta.internal.metals.MetalsLanguageServer.didChangeConfiguration(MetalsLanguageServer.scala:448)
    ... 16 more

@olafurpg Should I file an issue to make metals work with Graal VM ?

olafurpg commented 5 years ago

@ArulselvanMadhavan it seems your client is sending invalid JSON configuration with null values. We should report a helpful error in that case, please open a ticket in Metals.