scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.1k stars 332 forks source link

scala server crash using vscode w/metals: com.dhpcs:scala-json-rpc_2.12:2.0.1 not found #5262

Closed eswenson1 closed 1 year ago

eswenson1 commented 1 year ago

Describe the bug

I cannot run any scala project in vscode with scala metals. When the scala server is started, it runs for a bit and then I get the message that "The scala server crashed 5 times in the last 3 minutes...". Looking at the output window, I see that it was unable to download com.dhpcs:scala-json-rpc_2.12:2.0.1. I don't specify this in my project, so I'm assuming this is something that metals is trying to download.

I'm running on Ubuntu 22.04 LTS. I'm running metals 0.11.12. Coursier says that this is the latest and "cs update metals" doesn't update anything.

This happens with any scala sbt project.

Expected behavior

I expect the project to load and be able to be run. I have no issues with Intellij on any of my projects.

Operating system

Linux

Editor/Extension

VS Code

Version of Metals

v0.11.12

Extra context or search terms

ubuntu vscode metals com.dhpcs:scala-json-rpc_2.12

tgodzik commented 1 year ago

Thanks for reporting! Metals doesn't use com.dhpcs:scala-json-rpc_2.12:2.0.1. I double checked with coursier resolve and there is no occurrence of it at all.

Besides, Metals currently uses Scala 2.13, so it wouldn't use a 2.12 artifact.

Are you sure that you use the newest version?

eswenson1 commented 1 year ago

Any suggestions on how I could figure out where this dependency is coming from during the build? The error occurs after I see the message "Starting Metals Server...". I am using the latest version of metals, and when I use ps to see the metals process, I see that it is using 2.13 artifacts. I can reproduce this on a trivial gitter8 project -- hello-world. The only dependency in my build.sbt is the "org.scalameta" %% "munit" % "0.7.29" % Test.

The metals.sbt file has this:

addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.6")

And build.properties has:

sbt.version=1.8.2

So where is this coming from:

Error:
  com.dhpcs:scala-json-rpc_2.12:2.0.1:
    not found: /home/eswenson/.ivy2/local/com.dhpcs/scala-json-rpc_2.12/2.0.1/ivys/ivy.xml
    not found: https://repo1.maven.org/maven2/com/dhpcs/scala-json-rpc_2.12/2.0.1/scala-json-rpc_2.12-2.0.1.pom
    not found: https://dl.bintray.com/dhpcs/maven/com/dhpcs/scala-json-rpc_2.12/2.0.1/scala-json-rpc_2.12-2.0.1.pom
    not found: https://oss.sonatype.org/content/repositories/releases/com/dhpcs/scala-json-rpc_2.12/2.0.1/scala-json-rpc_2.12-2.0.1.pom
[Error - 8:51:10 AM] Connection to server got closed. Server will not be restarted.

The first messages in the "Scala Server" logs are:

Downloading https://repo1.maven.org/maven2/com/dhpcs/scala-json-rpc_2.12/2.0.1/scala-json-rpc_2.12-2.0.1.pom
Downloading https://repo1.maven.org/maven2/com/dhpcs/scala-json-rpc_2.12/2.0.1/scala-json-rpc_2.12-2.0.1.pom.sha1
Downloading https://dl.bintray.com/dhpcs/maven/com/dhpcs/scala-json-rpc_2.12/2.0.1/scala-json-rpc_2.12-2.0.1.pom
Downloading https://dl.bintray.com/dhpcs/maven/com/dhpcs/scala-json-rpc_2.12/2.0.1/scala-json-rpc_2.12-2.0.1.pom.sha1
Downloading https://oss.sonatype.org/content/repositories/releases/com/dhpcs/scala-json-rpc_2.12/2.0.1/scala-json-rpc_2.12-2.0.1.pom
Downloading https://oss.sonatype.org/content/repositories/releases/com/dhpcs/scala-json-rpc_2.12/2.0.1/scala-json-rpc_2.12-2.0.1.pom.sha1

Error:
  com.dhpcs:scala-json-rpc_2.12:2.0.1:
eswenson1 commented 1 year ago

I've tried the pre-release version of scala metals as well -- same thing.

tgodzik commented 1 year ago

This artifact seems to have been hosted on bintray, but it should have popped up much earlier if this was neccessary to use in Metals. Are you sure this is coming from metals?

If Metals created metals.sbt it means it should be running, but you say that it crashed. Also we don't use Scala Server logs, but there is Metals output. Did you maybe install an older extension at the same time?

eswenson1 commented 1 year ago

I'm wondering the same thing. Let me try again to remove all extensions -- I tried earlier, and when I restarted VS Code, I still saw some extensions I had uninstalled. Also, I confess to not really understanding the relationship between bloop and metals. Might the bloop configuration files and state in the .bloop subdirectory be causing some issue?

eswenson1 commented 1 year ago

I may have figured out what the issue was. I deleted my .bloop, .metals, .bsp, etc. directories, cleaned up the project directory, removed the target directory -- etc -- to get a pristine project again. I then deleted all extensions in VS Code except for the bare minimum required scala extensions.

I restarted vscode and didn't get the error. I think I may have used an old version or metals/bloop/bsp originally and this corrupted my project. When I later updated with coursier my metals/sbt/etc, and proved that I was running the latest version of metals (2.13-based), and was still getting the problem, it may have been some of the old state. I also had noticed that I had the "Scala Server" extension installed (since removed). Most likely it was the "Scala Server" extension, since the log messages with the error loading that scala-json-rpc artificact were in the "Scala Server" log window.

In any case, all is well now. Thanks much for your help.

tgodzik commented 1 year ago

Glad to be of help! Let us know if you find any more issues