Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to make a BSP connection with Bloop #2207

Closed
jqno opened this issue Nov 11, 2020 · 12 comments
Closed

Unable to make a BSP connection with Bloop #2207

jqno opened this issue Nov 11, 2020 · 12 comments
Labels
needs more information Use if we need more information for a specific ticket
Milestone

Comments

@jqno
Copy link

jqno commented Nov 11, 2020

Question

I saw on twitter there's a new release of coc-metals, so obviously I wanted to upgrade. After the upgrade though, the Metals server no longer starts for me. I reverted to the previous version, and it still doesn't start. Happens both on Maven and SBT projects.

I'm not sure if this is a Metals issue or a coc-metals issue, so I picked one. I'm happy to move this issue if I picked incorrectly :)

Installation:

  • Operating system: macOS
  • Vim or nvim version: 8.2.1650
  • coc.nvim version: commit 08190437e386c3841eaaa0c033ca4ee381d7eb78 -- I think that corresponds to 0.0.79
  • coc-metals extension version: commit eb0e501bd74bda475f463af5b7b645f639cf28ad -- I think that corresponds to 0.9.5
  • Metals version: 0.9.4

Additional context

I've tried adding an explicit metals.javaHome entry to make sure that the correct JVM is used, but it doesn't seem to help. It's managed with sdkman.io, if that's relevant.

Here's (part of) the content of my .metals/metals.log file:

2020.11.11 12:39:09 INFO  build tool exit: 0
2020.11.11 12:39:09 INFO  time: ran 'sbt bloopInstall' in 29s
Starting the bsp launcher for bloop...
Opening a bsp server connection with 'bsp --protocol local --socket /var/folders/j6/v64w7c6j40l9nlk85ndy9l480000gn/T/bsp-launcher980179579343575154/bsp.socket'...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
error: Giving up on waiting for a connection, printing embedded bloop logs:
> 
error: Trying a tcp-based connection to the server instead...
Opening a bsp server connection with 'bsp --protocol tcp --port 18436'...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
error: Giving up on waiting for a connection, printing embedded bloop logs:
> 
error: The launcher failed to establish a bsp connection, aborting...
2020.11.11 12:40:16 ERROR Failed to connect with build server, no functionality will work.
java.lang.RuntimeException: The server did not start, got FailedToOpenBspConnection
	at bloop.launcher.LauncherMain.failPromise$1(Launcher.scala:95)
	at bloop.launcher.LauncherMain.runLauncher(Launcher.scala:122)
	at scala.meta.internal.metals.BloopServers$$anon$1.run(BloopServers.scala:111)
	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:834)

Search terms

@ckipp01
Copy link
Member

ckipp01 commented Nov 11, 2020

Thanks for the report @jqno! So it's not specifically a coc-metals issue, but let's see if we can get it tackled first. We've seen this in a few places, and it's odd that Bloop is behaving this way.

Do you have Bloop CLI installed? If possible, there is a couple things you can try to help this out.

Firstly, make sure you're on the latest, which is > 1.4.5. With the new version of Metals you want to make sure you're not still on 1.4.4.x You can check this with a bloop about. If it's still 1.4.4.x, then do a bloop exit, and then open your workspace again with the latest Metals, and it should then start a new Bloop server with the correct version. My first suggestion is to that.

Also, looking again at the logs, Metals 0.9.4 will try the BSP connection once, and then time out. 0.9.5 has a built-in retry. So it's best to try with that. Again, if I had to guess, it would be that you still have an old Bloop running.

@ckipp01 ckipp01 changed the title Metals server doesn't start Unable to make a BSP connection with Bloop Nov 11, 2020
@jqno
Copy link
Author

jqno commented Nov 11, 2020

Thanks for the quick response! I've updated back to the most recent version of coc-metals (current commit) and done the things you said. According to the metals.log file, it's now on Metals version 0.9.5.

Indeed, I have Bloop CLI 1.4.4 installed locally through Coursier. (Maybe I should remove it? I never run it directly.)

When I do bloop exit, I get the following as part of the output in metals.log:

Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
error: Giving up on waiting for a connection, printing embedded bloop logs:
> No server running at 127.0.0.1:8212, let's fire one...
> Resolving ch.epfl.scala:bloop-frontend_2.12:1.4.5-2-eb51d668...
> Starting bloop server at 127.0.0.1:8212...
> Attempting a connection to the server...
error: Trying a tcp-based connection to the server instead...
Opening a bsp server connection with 'bsp --protocol tcp --port 22705'...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...

So it seems like that is using the more recent version of Bloop, but it still ends up in the same stacktrace.

@ckipp01
Copy link
Member

ckipp01 commented Nov 11, 2020

Indeed, I have Bloop CLI 1.4.4 installed locally through Coursier. (Maybe I should remove it? I never run it directly.)

If you have it installed vial cs, you should be able to do a cs update bloop to ensure it's up to date. In the logs this time, did you see it try 5 times? Either way, I can see in your last logs that you do have the latest Bloop, so I'm unsure what's going on. I'm going to transfer this to the main repo to maybe get some more input.

@ckipp01 ckipp01 transferred this issue from scalameta/coc-metals Nov 11, 2020
@jqno
Copy link
Author

jqno commented Nov 11, 2020

I've updated bloop as you said, it's now at 1.4.5.something. I only see it retrying twice, though. Relevant sections of the log:

2020.11.11 13:51:57 INFO  mvn bloopInstall exit: 0
2020.11.11 13:51:58 INFO  time: ran 'mvn bloopInstall' in 10s
2020.11.11 13:51:58 INFO  Attempting to connect to the build server...
Starting the bsp launcher for bloop...
Opening a bsp server connection with 'bsp --protocol local --socket /var/folders/j6/v64w7c6j40l9nlk85ndy9l480000gn/T/bsp-launcher5348833836309647595/bsp.socket'...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
error: Giving up on waiting for a connection, printing embedded bloop logs:
> No server running at 127.0.0.1:8212, let's fire one...
> Resolving ch.epfl.scala:bloop-frontend_2.12:1.4.5-2-eb51d668...
> Starting bloop server at 127.0.0.1:8212...
> Attempting a connection to the server...
error: Trying a tcp-based connection to the server instead...
Opening a bsp server connection with 'bsp --protocol tcp --port 39176'...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
Waiting for the bsp connection to come up...
error: Giving up on waiting for a connection, printing embedded bloop logs:
> No server running at 127.0.0.1:8212, let's fire one...
> Resolving ch.epfl.scala:bloop-frontend_2.12:1.4.5-2-eb51d668...
> Starting bloop server at 127.0.0.1:8212...
> Attempting a connection to the server...
error: The launcher failed to establish a bsp connection, aborting...
2020.11.11 13:53:05 ERROR Failed to connect with build server, no functionality will work.
java.lang.RuntimeException: The server did not start, got FailedToOpenBspConnection
	at bloop.launcher.LauncherMain.failPromise$1(Launcher.scala:95)
	at bloop.launcher.LauncherMain.runLauncher(Launcher.scala:122)
	at scala.meta.internal.metals.BloopServers$$anon$1.run(BloopServers.scala:158)
	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:834)

@tgodzik
Copy link
Contributor

tgodzik commented Nov 12, 2020

Thanks for reporting! Is this problematic in every workspace or just one? Did you try removing .bloop and .metals directories?

@jqno
Copy link
Author

jqno commented Nov 12, 2020

I've tried in 2 workspaces, one maven and one sbt. I've removed these directories several times, but it didn't help. I haven't done an in depth comparison between the two workspaces, but the effects seem the same.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 12, 2020

The weirdest thing is that it used to work for you without problems. Did you maybe change the default java version? Was there anything at all that you changed aside from Metals version? Especially if you reverted it should just go back to normal. Could you try running with 0.9.4 Metals version? With the older Bloop 1.4.4 running?

@tgodzik tgodzik added the needs more information Use if we need more information for a specific ticket label Nov 12, 2020
@jqno
Copy link
Author

jqno commented Nov 13, 2020

Thanks for all the help, @ckipp01 and @tgodzik. I'm a little embarrased to say, after a restart of my machine, everything worked perfectly again. Should've thought about this earlier, I work in IT after all 😅

Just to give you all the information that you asked for, in case it may be of help later:

  • I didn't change the default Java version. I have several JVMs on my machine for hobby projects, but there's only one that has the required security configuration to be able to connect to servers at work, so I'm mostly bound to that one JVM (OpenJDK 11.0.8+10, on macOS).
  • Initially, I only changed the Metals version (through updating coc-metals). Then I reverted and saw the same behaviour. Only later did I update Bloop from 1.4.4 to 1.4.5, though I don't remember if I did that before or after going back to the most recent versions of Metals and coc-metals. After that, I still had the same problems.

This morning, I restarted my machine to install a software update (no, not the Big Sur one yet, I'll wait a bit before I do that one 😉) and things worked again, both in my Maven project and my SBT project.

@ckipp01
Copy link
Member

ckipp01 commented Nov 13, 2020

Thanks for all the help, @ckipp01 and @tgodzik. I'm a little embarrased to say, after a restart of my machine, everything worked perfectly again. Should've thought about this earlier, I work in IT after all 😅

🎉 ha, glad it's working!! Although, again, it's not ideal that this happened in the first place. Thanks for all the info that you have us. The issue you described is something we're aware of and have seen pop up a couple times. We do have some ideas and things that we'll be trying to remedy this situation where a user is simply unable to connect to the server. So hopefully these situations will be become more rare. If you have this happen again, feel free to pop in here and let us know.

@ckipp01 ckipp01 closed this as completed Nov 13, 2020
@jqno
Copy link
Author

jqno commented Nov 13, 2020

Thanks, I will let you know if I run into it again. In the mean time, if there's something I can do to help with this, please let me know!

@talestonini
Copy link

I experienced exactly the same issue:

> Starting bloop server at 127.0.0.1:8212...
> Attempting a connection to the server...
error: The launcher failed to establish a bsp connection, aborting...

And after much debugging and arriving at this page I can confirm that simply restarting the machine did the trick.

@tgodzik tgodzik added this to the Metals v0.11.10 milestone Dec 13, 2022
@Prikaz98
Copy link

Prikaz98 commented Mar 7, 2024

I've got the same problem when I killed and relaunched my emacs. I noticed that bloop process still works and metals can't connect to them. If kill this bloop process everything will work and do reboot isn't necessarily

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more information Use if we need more information for a specific ticket
Projects
None yet
Development

No branches or pull requests

5 participants