Describe the bug
If we try to connect to the sbt BSP server on a project that has a compile error, it will not succeed
To Reproduce
Steps to reproduce the behavior:
Expected behavior
sbt just reports the error.
Installation:
Additional context
This was raised on gitter
Search terms
sbt BSP compile error
Thanks for reporting this @tgodzik! Although I'm unable to reproduce it. This is what I did to test it.
Main.scala and added a val hi: String = 3.metals.generate-bsp-config which created the .bsp/sbt.json and then attempted to connect.It did connect correctly, and in the logs I see this:
2021.01.04 16:50:17 INFO Attempting to connect to the build server...
2021.01.04 16:50:17 INFO tracing is enabled: /Users/ckipp/Library/Caches/org.scalameta.metals/bsp.trace.json
2021.01.04 16:50:23 INFO time: connected to build server in 6.03s
2021.01.04 16:50:23 INFO Connected to Build server v1.4.6
2021.01.04 16:50:23 INFO Processing
2021.01.04 16:50:23 INFO Processing
2021.01.04 16:50:23 INFO Processing
2021.01.04 16:50:23 INFO Processing
2021.01.04 16:50:23 INFO Processing
2021.01.04 16:50:23 INFO Processing
2021.01.04 16:50:23 INFO Processing
2021.01.04 16:50:24 INFO time: imported build in 1.43s
2021.01.04 16:50:24 INFO Processing
2021.01.04 16:50:24 INFO time: indexed workspace in 0.6s
2021.01.04 16:50:25 WARN no build target for: /Users/ckipp/Documents/scala-workspace/tester/build.sbt
2021.01.04 16:50:24 INFO Processing
2021.01.04 16:50:24 INFO compiling root
2021.01.04 16:50:24 INFO compiling 2 Scala sources to /Users/ckipp/Documents/scala-workspace/tester/target/scala-2.13/classes ...
2021.01.04 16:50:25 INFO Non-compiled module 'compiler-bridge_2.13' for Scala 2.13.4. Compiling...
2021.01.04 16:50:32 INFO Compilation completed in 6.949s.
2021.01.04 16:50:32 ERROR /Users/ckipp/Documents/scala-workspace/tester/src/main/scala/example/Main.scala:13:20: type mismatch;
found : Int(3)
required: String
2021.01.04 16:50:32 ERROR val hi: String = 3
2021.01.04 16:50:32 ERROR ^
2021.01.04 16:50:32 ERROR one error found
2021.01.04 16:50:32 INFO time: compiled root in 7.69s
2021.01.04 16:50:32 ERROR (Compile / compileIncremental) Compilation failed
I'm assuming this isn't what you're seeing?
It seems I can no longer reproduce it :thinking: I thought I've seen it a number of times, but maybe new sbt version fixed it? Or I was doing something totally wrong. Either way I will close it and we can reopen if I ever encounter it again.
Hi, I was the person who reported this on Gitter. I can (still) reproduce this.
here's what I do:
git clone https://github.com/asflierl/sglicko2.git (it is a very small & simple project)cd sglicko2git checkout db0b84787dcbf1bcceb37db3abf44ba2129c78ecsbtn compile (this will report a compile error)code .I got SBT 1.4.6 installed, Metals updated to 0.9.8 and using GraalVM CE 20.3.0 for Java 11.
Anything else I can do to help diagnose this? @tgodzik @ckipp01
Hey @asflierl I just pulled down your repo and indeed, it does fail for me as well!
2021.01.05 16:37:03 ERROR }x
2021.01.05 16:37:03 ERROR ^
2021.01.05 16:37:03 ERROR one error found
2021.01.05 16:37:03 ERROR (Compile / compileIncremental) Compilation failed
2021.01.05 16:37:03 INFO Processing
2021.01.05 16:37:03 INFO Disconnecting from sbt session...
2021.01.05 16:37:03 INFO Shut down connection with build server.
2021.01.05 16:37:03 ERROR Failed to connect with build server, no functionality will work.
org.eclipse.lsp4j.jsonrpc.ResponseErrorException:
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
at org.eclipse.lsp4j.jsonrpc.TracingMessageConsumer.consume(TracingMessageConsumer.java:114)
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
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: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)
馃 I'm not fully sure why in this instance it behaves differently than with a minimal reproduction. I'll have to dive into this a bit more to figure out why it's disconnecting in this scenario and not the other. Thanks for following up!