scala – Metals VS Code connection to build server failing

I’ve set up a Scala project with the metals extension and when importing the build.sbt, this fails and im provided with the following error message and this metals.log
Failed to connect with build server, no functionality will work. See logs for more details.

metals.log
Due to there only being 30.000 chars allowed and the log being 40.000+ I’ve shared it via a link.
The short version would be this:

2022.06.11 15:33:58 INFO  tracing is disabled for protocol LSP, to enable tracing of incoming and outgoing JSON messages create an empty file at c:UsersUSERDocumentsWORKSPACE.metalslsp.trace.json or C:UsersUSERAppDataLocalscalametametalscachelsp.trace.json
2022.06.11 15:34:03 INFO  logging to file C:UsersUSERDocumentsWORKSPACE.metalsmetals.log
2022.06.11 15:34:03 INFO  Started: Metals version 0.11.6 in workspace 'C:UsersUSERDocumentsWORKSPACE' for client Visual Studio Code 1.68.0.
2022.06.11 15:34:10 INFO  time: initialize in 7.57s
2022.06.11 15:34:13 WARN  Flyway upgrade recommended: H2 2.1.212 is newer than this version of Flyway and support has not been tested. The latest supported version of H2 is 2.1.210.
2022.06.11 15:34:14 WARN  Build server is not auto-connectable.
2022.06.11 15:34:22 WARN  no build target for: C:UsersUSERDocumentsWORKSPACEsrcmainscalaex08Run.scala
2022.06.11 15:34:28 INFO  running 'C:Program FilesJavajdk-11.0.14binjava -Djline.terminal=jline.UnsupportedTerminal -Dsbt.log.noformat=true -Dfile.encoding=UTF-8 -jar C:UsersUSERAppDataLocalTempmetals10676834532196762278sbt-launch.jar -Dbloop.export-jar-classifiers=sources bloopInstall'
2022.06.11 15:34:38 INFO  no build target found for C:UsersUSERDocumentsWORKSPACEsrcmainscalaex08Run.scala. Using presentation compiler with project's scala-library version: 3.1.2
2022.06.11 15:34:46 INFO  [info] welcome to sbt 1.6.2 (Oracle Corporation Java 11.0.14)
2022.06.11 15:34:51 INFO  [info] loading settings for project exercises-build-build-build from metals.sbt ...
2022.06.11 15:34:52 INFO  time: code lens generation in 23s
2022.06.11 15:34:52 INFO  time: code lens generation in 24s
2022.06.11 15:34:52 INFO  time: code lens generation in 28s
2022.06.11 15:34:52 INFO  time: code lens generation in 28s
2022.06.11 15:34:54 INFO  [info] loading project definition from C:UsersUSERDocumentsWORKSPACEprojectprojectproject
2022.06.11 15:34:57 INFO  [info] loading settings for project exercises-build-build from metals.sbt ...
2022.06.11 15:34:57 INFO  [info] loading project definition from C:UsersUSERDocumentsWORKSPACEprojectproject
2022.06.11 15:35:10 INFO  [success] Generated .bloopexercises-build-build.json
2022.06.11 15:35:10 INFO  [success] Total time: 11 s, completed 11.06.2022, 15:35:10
2022.06.11 15:35:11 INFO  [info] loading settings for project exercises-build from metals.sbt ...
2022.06.11 15:35:11 INFO  [info] loading project definition from C:UsersUSERDocumentsWORKSPACEproject
2022.06.11 15:35:16 INFO  [success] Generated .bloopexercises-build.json
2022.06.11 15:35:16 INFO  [success] Total time: 5 s, completed 11.06.2022, 15:35:16
2022.06.11 15:35:16 INFO  [info] loading settings for project root from build.sbt ...
2022.06.11 15:35:17 INFO  [info] set current project to exercises (in build file:/C:/Users/USER/Documents/WORKSPACE/)
2022.06.11 15:35:19 INFO  [success] Generated .blooproot.json
2022.06.11 15:35:19 INFO  [success] Generated .blooproot-test.json
2022.06.11 15:35:19 INFO  [success] Total time: 1 s, completed 11.06.2022, 15:35:19
2022.06.11 15:35:20 INFO  time: ran 'sbt bloopInstall' in 51s
2022.06.11 15:35:20 INFO  Attempting to connect to the build server...
2022.06.11 15:35:36 ERROR Starting the bsp launcher for bloop...
2022.06.11 15:35:36 ERROR Opening a bsp server connection with 'bsp --protocol tcp --port 24387'...
2022.06.11 15:35:36 ERROR Waiting for the bsp connection to come up...
2022.06.11 15:35:36 ERROR Waiting for the bsp connection to come up...
2022.06.11 15:35:36 ERROR Waiting for the bsp connection to come up...
2022.06.11 15:35:36 ERROR Waiting for the bsp connection to come up...
2022.06.11 15:35:36 ERROR Waiting for the bsp connection to come up...
2022.06.11 15:35:36 ERROR Waiting for the bsp connection to come up...
2022.06.11 15:35:36 ERROR error: The command bsp --protocol tcp --port 24387 returned with an error
2022.06.11 15:35:36 ERROR > No server running at 127.0.0.1:8212, let's fire one...
2022.06.11 15:35:36 ERROR > Resolving ch.epfl.scala:bloop-frontend_2.12:1.5.0-18-003e6c7b...
2022.06.11 15:35:36 ERROR > Attempting a connection to the server...
2022.06.11 15:35:36 ERROR > Starting bloop server at 127.0.0.1:8212...
2022.06.11 15:35:36 ERROR > java.io.IOException: Cannot run program "C:Program FilesJavajdk-11.0.12binjava" (in directory "c:UsersUSERDocumentsWORKSPACE"): CreateProcess error=2, Das System kann die angegebene Datei nicht finden
2022.06.11 15:35:36 ERROR >     at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
2022.06.11 15:35:36 ERROR >     at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
2022.06.11 15:35:36 ERROR >     at bloop.bloopgun.BloopgunCli.sysproc$1(Bloopgun.scala:487)
2022.06.11 15:35:36 ERROR >     at bloop.bloopgun.BloopgunCli.sysprocWithJava$1(Bloopgun.scala:502)
2022.06.11 15:35:36 ERROR >     at bloop.bloopgun.BloopgunCli.startServer(Bloopgun.scala:546)
2022.06.11 15:35:36 ERROR >     at bloop.bloopgun.BloopgunCli$FireInBackground$.$anonfun$fire$1(Bloopgun.scala:314)
2022.06.11 15:35:36 ERROR >     at bloop.bloopgun.core.Shell$$anon$2.run(Shell.scala:152)
2022.06.11 15:35:36 ERROR > Caused by: java.io.IOException: CreateProcess error=2, Das System kann die angegebene Datei nicht finden
2022.06.11 15:35:36 ERROR >     at java.base/java.lang.ProcessImpl.create(Native Method)
2022.06.11 15:35:36 ERROR >     at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:487)
2022.06.11 15:35:36 ERROR >     at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:154)
2022.06.11 15:35:36 ERROR >     at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
2022.06.11 15:35:36 ERROR >     ... 6 more
2022.06.11 15:35:36 ERROR > Starting bloop server at 127.0.0.1:8212...
2022.06.11 15:35:36 ERROR > java.io.IOException: Cannot run program "C:Program FilesJavajdk-11.0.12binjava" (in directory "c:UsersUSERDocumentsWORKSPACE"): CreateProcess error=2, Das System kann die angegebene Datei nicht finden
2022.06.11 15:35:36 ERROR >     at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
2022.06.11 15:35:36 ERROR >     at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
2022.06.11 15:35:36 ERROR >     at bloop.bloopgun.BloopgunCli.sysproc$1(Bloopgun.scala:487)
2022.06.11 15:35:36 ERROR >     at bloop.bloopgun.BloopgunCli.sysprocWithJava$1(Bloopgun.scala:502)
2022.06.11 15:35:36 ERROR >     at bloop.bloopgun.BloopgunCli.startServer(Bloopgun.scala:562)
2022.06.11 15:35:36 ERROR >     at bloop.bloopgun.BloopgunCli$FireInBackground$.$anonfun$fire$1(Bloopgun.scala:314)
2022.06.11 15:35:36 ERROR >     at bloop.bloopgun.core.Shell$$anon$2.run(Shell.scala:152)
2022.06.11 15:35:36 ERROR > Caused by: java.io.IOException: CreateProcess error=2, Das System kann die angegebene Datei nicht finden
2022.06.11 15:35:36 ERROR >     at java.base/java.lang.ProcessImpl.create(Native Method)
2022.06.11 15:35:36 ERROR >     at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:487)
2022.06.11 15:35:36 ERROR >     at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:154)
2022.06.11 15:35:36 ERROR >     at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
2022.06.11 15:35:36 ERROR >     ... 6 more

[MISSING BLOCK, SEE LINK]

2022.06.11 15:35:36 ERROR > Error: Cannot run program "C:Program FilesJavajdk-11.0.12binjava" (in directory "c:UsersUSERDocumentsWORKSPACE"): CreateProcess error=2, Das System kann die angegebene Datei nicht finden'
2022.06.11 15:35:36 ERROR > Attempt connection a last time before giving up...
2022.06.11 15:35:36 ERROR > Attempting a connection to the server...
2022.06.11 15:35:36 ERROR > error: Server could not be started at None:Some(8212)! Giving up...
2022.06.11 15:35:36 ERROR error: The launcher failed to establish a bsp connection, aborting...
2022.06.11 15:35:36 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$2.run(BloopServers.scala:434)
    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)

(There are some bits of German which hopefully aren’t important to understand)

Hopefully someone knows why this happens and how to fix it.

Leave a Comment