question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scala Metals fails

See original GitHub issue

Scala Metals is a language server that communicates over JSON-RPC. It can be installed with

curl -Lo coursier https://git.io/coursier-cli && chmod +x coursier
./coursier bootstrap org.scalameta:metals_2.12:0.7.0 -o metals -f`

The contents of my servers.yml:

langservers:
  scala:
    - /Users/marduk/metals

I launched Jupyter Lab as follows:

node miniconda3/share/jupyter/lab/staging/node_modules/jsonrpc-ws-proxy/dist/server.js --port 3000 --languageServers servers.yml 

jupyter lab

I created a Scala notebook (using the Almond kernel) and in ~/Library/Caches/org.scalameta.metals/global.log I got the following error:

INFO  tracing is disabled for protocol LSP, to enable tracing of incoming and outgoing JSON messages create an empty file at /Users/marduk/Library/Caches/org.scalameta.metals/lsp.trace.json
INFO  Starting Metals server with configuration: MetalsServerConfig(
  bloop-protocol=BloopProtocol(auto),
  glob-syntax=GlobSyntaxConfig(uri),
  status-bar=StatusBarConfig(off),
  slow-task=SlowTaskConfig(off),
  execute-client-command=ExecuteClientCommandConfig(off),
  show-message=ShowMessageConfig(on),
  show-message-request=ShowMessageRequestConfig(on),
  no-initialized=false,
  compilers=PresentationCompilerConfigImpl(false,None,None,Map(scala/collection/mutable/ -> mutable., java/util/ -> ju.),Ascii,true,true,true,true,true,20,SECONDS),
  http=false,
  input-box=false,
  icons=none,
  statistics=StatisticsConfig(default)
)
INFO  logging to file /.metals/metals.log
Sep 01, 2019 9:45:07 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
SEVERE: Internal error: java.nio.file.AccessDeniedException: /.metals

So it seems that Metals cannot create the directory .metals in the current workspace. I did some research and it appears that the workspace for the language server is set by jsonrpc-ws-proxy/dist/server.js.

Metals works in all the major editors, but it would be awesome to have it available in JupyterLab. See Integrating a new editor for details.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
sbrunkcommented, Nov 4, 2019

Since #92 has been merged, I just tried again using a dev build on master. I get a fully resolved path under $HOME now and Metals starts up fine! 🎉

Thanks for the fast fix! I guess this issue can be closed now.

2reactions
sbrunkcommented, Nov 3, 2019

Thank you all for the pointers! This is how rootUri looks in the init message:

[Trace - 08:11:28 AM] Received request 'initialize - (0)'
Params: {
  "processId": null,
  "rootUri": "file:///~/tmp/jupyterlab-lsp",
  ...

I tried starting jupyter lab from somewhere outside $HOME as suggested by @bollwyvl and it seems Metals is starting up normally. I can see it creating its startup files, there’s LSP communication in lsp.trace.json, and the status bar says "fully initialized.

grafik

We still don’t get back anything really usable as most answers are empty.

[Trace - 06:58:41 PM] Sending notification 'textDocument/publishDiagnostics'
Params: {
  "uri": "file:///private/tmp/jupyter-lsp/scala.ipynb",
  "diagnostics": []
}

But I assume that’s because Metals doesn’t support Scala script files yet and has nothing to do with jupyterlab-lsp.

So I guess fully resolving rootPath on the server (#91) should solve the issue here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Metals will not connect to sbt if compilation fails · Issue #2347
scala and added a val hi: String = 3 . Executed a metals.generate-bsp-config which created the .bsp/sbt.json and then attempted to connect.
Read more >
Proxy and mirrors | Metals
ERROR Failed to connect with build server, no functionality will work. java.lang.RuntimeException: The server did not start, got FailedToOpenBspConnection
Read more >
scalameta/metals - Gitter
Metals keeps trying to compile forever. I'm seeing this in the logs No progress update for 30 seconds caused bloop to cancel compilation...
Read more >
Metals VS Code connection to build server failing
I've set up a Scala project with the metals extension and when importing the the build.sbt, this fails and im provided with the...
Read more >
Problems building with Scala Metals and Chisel v3.4.0
I got this error in Scala Metals today. ERROR Unexpected error when compiling fiddlybob: 'Multiple phases want to run right after typer; followers: ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found