Metals: Java from javaHome setting is not available on path for Bloop

Created on 14 Jan 2020  路  13Comments  路  Source: scalameta/metals

I'm using vscode with Metals and it's recently started giving me this error:

Starting the bsp launcher for bloop...
Opening a bsp server connection with 'bsp --protocol tcp --port 44559'...
Waiting for the bsp connection to come up...
error: The command bsp --protocol tcp --port 44559 returned with an error
> 
error: The launcher failed to establish a bsp connection, aborting...
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:92)
    at bloop.launcher.LauncherMain.runLauncher(Launcher.scala:119)
    at scala.meta.internal.metals.BloopServers$$anon$1.run(BloopServers.scala:101)
    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)

INFO  no build target: using presentation compiler with only scala-library

It was working perfectly fine a couple days ago but now no project can connect to the server. I'm running Windows 10, OpenJDK 11, Scala 2.13.1 and SBT 1.3.5.

I've tried clearing out the .metals and .bloop folders from the project and tried reinstalling the metals plugin to no avail.

bug

All 13 comments

Thank you for reporting! Do you have Bloop installed on your computer or only Metals?

@PaperPlaneSoftware thanks for reporting. I got exactly the same error in the past and it was due to an old Bloop server running on my computer.

Killing the old server and reloading the VS Code window fixed it for me.

Thank you for reporting! Do you have Bloop installed on your computer or only Metals?

I have both. If I start bloop manually bloop server and then run vscode it works. So it looks like it's a problem with the bloop that ships with Metals?

Thank you for reporting! Do you have Bloop installed on your computer or only Metals?

I have both. If I start bloop manually bloop server and then run vscode it works. So it looks like it's a problem with the bloop that ships with Metals?

The embdeed one should work fine, but it doesn't seem to start. Are there any other logs that could indicate for example that semanticDB was not downloaded?

I also got these problems just after upgrading to 0.8.0, I am on vscode version 1.41.1. I don't have another server running. I also get this error in my metals logs:

WARN  jar error: /home/scalavision/.cache/coursier/v1/https/repo1.maven.org/maven2/com/openhtmltopdf/openhtmltopdf-rtl-support/0.0.1-RC19/openhtmltopdf-rtl-support-0.0.1-RC19-sources.jar
java.io.UncheckedIOException: java.nio.file.NoSuchFileException: /Users

Seems there is some hardcoded path there. Don't know if that is the reason why bloop is not starting ...
In addition I get:

WARN  no build target for: <path to scala file in the project goes here>

Luckily, downgrading to 0.7.6 makes everything work again :-)

I also got these problems just after upgrading to 0.8.0, I am on vscode version 1.41.1. I don't have another server running. I also get this error in my metals logs:

WARN  jar error: /home/scalavision/.cache/coursier/v1/https/repo1.maven.org/maven2/com/openhtmltopdf/openhtmltopdf-rtl-support/0.0.1-RC19/openhtmltopdf-rtl-support-0.0.1-RC19-sources.jar
java.io.UncheckedIOException: java.nio.file.NoSuchFileException: /Users

Seems there is some hardcoded path there. Don't know if that is the reason why bloop is not starting ...
In addition I get:

WARN  no build target for: <path to scala file in the project goes here>

Luckily, downgrading to 0.7.6 makes everything work again :-)

That is just a warning, it doesn't cause any issues. Is there anything else in the logs?

@tgodzik , sorry for late reply, I don't have this setup at work.

I think I've found the error:

Exception in thread "bloop-server-background" java.io.IOException: Cannot run program "java" (in directory "<some path here ...>"): error=2, No such file or directory
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)

I don't have java in my path. This is intentional, so I've configured the path to the jdk via the metals: Java Home option in settings.

This seems to work in 0.7.6 but not in 0.8.0.

After adding java to the path, everything seems to work, also on more advanced project setups.

Thank you for looking into this! I hope the feedback is helpful :-)

@scalavision Thanks! That actually now makes sense. We might need to set JAVA_HOME in Metals for Bloop to use.

After some investigation I think what we need to do it provide java in the PATH variable. This might just be needed for the VS Code extension, especially when we download java automatically.

Confirmed as working after the fix in Bloop :tada:

I am facing the same problem, and I have set java home to PATH. The log shows here:

####log starts

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.0-RC1-190-ef7d8dba...
error: The launcher failed to establish a bsp connection, aborting...
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:104)
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)

#####log ends

I am running on java 8, windows 7, Vscode 1.44.1 and metals 1.8.6. I have installed bloop plugin in plugin.sbt and I am not sure if this is called "install bloop". Thanks for your reply.

I am facing the same problem, and I have set java home to PATH. The log shows here:

@z00420691 You need to specify JAVA_HOME or you can specify the version in settings metals.javaHome, which will forward that home to Bloop.

Edit: If that doesn't help, let's open a separate issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tSte picture tSte  路  27Comments

olafurpg picture olafurpg  路  15Comments

LukaszByczynski picture LukaszByczynski  路  30Comments

dos65 picture dos65  路  15Comments

olafurpg picture olafurpg  路  14Comments