Metals: Import project fails with RuntimeException

Created on 11 Mar 2019  Â·  13Comments  Â·  Source: scalameta/metals

Describe the bug

When starting vscode in a sbt-project directory the project import is offered.
I get this error:

Import project failed, no functionality will work. See the logs for more details
````
and this in my metals.log

java.lang.RuntimeException: CreateProcessW() failed, error: 193
at com.zaxxer.nuprocess.windows.WindowsProcess.start(WindowsProcess.java:248)
at com.zaxxer.nuprocess.windows.WinProcessFactory.createProcess(WinProcessFactory.java:42)
at com.zaxxer.nuprocess.NuProcessBuilder.start(NuProcessBuilder.java:266)
at scala.meta.internal.metals.BloopInstall.runArgumentsUnconditionally(BloopInstall.scala:103)
at scala.meta.internal.metals.BloopInstall.runUnconditionally(BloopInstall.scala:80)
at scala.meta.internal.metals.BloopInstall.$anonfun$runIfApproved$2(BloopInstall.scala:157)
at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
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)
INFO sbt exit: -2147483648
INFO time: ran 'sbt bloopInstall' in 1.61s
ERROR sbt command failed: C:\cygwin64\usr\local\bin\sbt metalsEnable bloopInstall

When I restart vscode after the first failure I get this error in metals.log next

INFO time: initialize in 0.15s
INFO skipping build import with status 'Failed'
```

To Reproduce Steps to reproduce the behavior:

  1. Open vscode in a scala project
  2. Accept the import of the project
  3. See error

Expected behavior

I expect the project import to work and that the .bloop directory is created

Installation:

  • Operating system: Windows 7 x64
  • VSCode version: 1.32.1
  • VSCode extension version: 1.2.7
  • Metals version: 0.4.4

Search terms

metals import project windows

Most helpful comment

A workaround is to manually run the following from the console

METALS_ENABLED=true sbt metalsEnable bloopInstall

This step needs to run every time the build changes or when you remove the .bloop directory.

When Metals asks to "Import changes" you can select "Don't show again" to dismiss those questions in the future. We rely on NuProcess because it allows us to expose a Future[Int] for the sbt process, which I couldn't figure out how to do with java.lang.ProcessBuilder.

All 13 comments

Thanks for reporting! What happens if you run the following command manually? (I don't know the exact windows syntax so it may need adjusting)

export METALS_ENABLED=true
C:\cygwin64\usr\local\bin\sbt metalsEnable bloopInstall

This is my output when running the command in my terminal (cygwin + zsh)

î‚° export METALS_ENABLED=true
î‚° sbt clean
[info] Loading settings for project global-plugins from credentials.sbt,idea.sbt,metals.sbt,sbt-updates.sbt ...
[info] Loading global plugins from C:\Users\r892107\.sbt\1.0\plugins
[info] Updating ProjectRef(uri("file:/C:/Users/r892107/.sbt/1.0/plugins/"), "global-plugins")...
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/org/scalameta/sbt-metals_2.12_1.0/0.4.4/sbt-metals-0.4.4.jar ...
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/io/circe/circe-jawn_2.12/0.9.3/circe-jawn_2.12-0.9.3.jar ...
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/io/circe/circe-derivation_2.12/0.9.0-M3/circe-derivation_2.12-0.9.0-M3.jar ...
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/io/circe/circe-parser_2.12/0.9.3/circe-parser_2.12-0.9.3.jar ...
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/ch/epfl/scala/bloop-config_2.12/1.2.5/bloop-config_2.12-1.2.5.jar ...
[info]  [SUCCESSFUL ] org.scalameta#sbt-metals;0.4.4!sbt-metals.jar (562ms)
[info]  [SUCCESSFUL ] io.circe#circe-parser_2.12;0.9.3!circe-parser_2.12.jar (218ms)
[info]  [SUCCESSFUL ] io.circe#circe-derivation_2.12;0.9.0-M3!circe-derivation_2.12.jar (281ms)
[info]  [SUCCESSFUL ] io.circe#circe-jawn_2.12;0.9.3!circe-jawn_2.12.jar (312ms)
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/io/circe/circe-core_2.12/0.9.3/circe-core_2.12-0.9.3.jar ...
[info]  [SUCCESSFUL ] ch.epfl.scala#bloop-config_2.12;1.2.5!bloop-config_2.12.jar (390ms)
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/org/spire-math/jawn-parser_2.12/0.11.1/jawn-parser_2.12-0.11.1.jar ...
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/io/circe/circe-numbers_2.12/0.9.3/circe-numbers_2.12-0.9.3.jar ...
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/org/typelevel/cats-core_2.12/1.0.1/cats-core_2.12-1.0.1.jar ...
[info]  [SUCCESSFUL ] io.circe#circe-numbers_2.12;0.9.3!circe-numbers_2.12.jar (203ms)
[info]  [SUCCESSFUL ] org.spire-math#jawn-parser_2.12;0.11.1!jawn-parser_2.12.jar (374ms)
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/org/typelevel/cats-kernel_2.12/1.0.1/cats-kernel_2.12-1.0.1.jar ...
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/org/typelevel/cats-macros_2.12/1.0.1/cats-macros_2.12-1.0.1.jar ...
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/org/typelevel/machinist_2.12/0.6.2/machinist_2.12-0.6.2.jar ...
[info]  [SUCCESSFUL ] io.circe#circe-core_2.12;0.9.3!circe-core_2.12.jar (748ms)
[info]  [SUCCESSFUL ] org.typelevel#cats-macros_2.12;1.0.1!cats-macros_2.12.jar (328ms)
[info]  [SUCCESSFUL ] org.typelevel#machinist_2.12;0.6.2!machinist_2.12.jar (344ms)
[info]  [SUCCESSFUL ] org.typelevel#cats-core_2.12;1.0.1!cats-core_2.12.jar (3167ms)
[info]  [SUCCESSFUL ] org.typelevel#cats-kernel_2.12;1.0.1!cats-kernel_2.12.jar (2948ms)
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/ch/epfl/scala/sbt-bloop_2.12_1.0/1.2.5/sbt-bloop-1.2.5.jar ...
[info]  [SUCCESSFUL ] ch.epfl.scala#sbt-bloop;1.2.5!sbt-bloop.jar (265ms)
[info] Done updating.
[info] Loading settings for project topgun-build from plugins.sbt ...
[info] Loading project definition from C:\cygwin64\home\r892107\sourcecode\topgun\project
[info] Updating ProjectRef(uri("file:/C:/cygwin64/home/r892107/sourcecode/topgun/project/"), "topgun-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[success] Generated .bloop\topgun-build.json
[success] Total time: 12 s, completed 11.03.2019 14:04:25
[info] Updating ProjectRef(uri("file:/C:/cygwin64/home/r892107/sourcecode/topgun/project/"), "topgun-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Loading settings for project root from build.sbt ...
[info] Set current project to topgun (in build file:/C:/cygwin64/home/r892107/sourcecode/topgun/)
[success] Total time: 0 s, completed 11.03.2019 14:04:46
î‚° sbt metalsEnable bloopInstall
[info] Loading settings for project global-plugins from credentials.sbt,idea.sbt,metals.sbt,sbt-updates.sbt ...
[info] Loading global plugins from C:\Users\r892107\.sbt\1.0\plugins
[info] Loading settings for project topgun-build from plugins.sbt ...
[info] Loading project definition from C:\cygwin64\home\r892107\sourcecode\topgun\project
[success] Generated .bloop\topgun-build.json
[success] Total time: 8 s, completed 11.03.2019 14:05:47
[info] Loading settings for project root from build.sbt ...
[info] Set current project to topgun (in build file:/C:/cygwin64/home/r892107/sourcecode/topgun/)
[info] Set current project to topgun (in build file:/C:/cygwin64/home/r892107/sourcecode/topgun/)
[info] semanticdb-scalac is enabled
[info] Updating ...
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/org/scalameta/semanticdb-scalac_2.12.8/4.1.4/semanticdb-scalac_2.12.8-4.1.4.jar ...
[info]  [SUCCESSFUL ] org.scalameta#semanticdb-scalac_2.12.8;4.1.4!semanticdb-scalac_2.12.8.jar (6381ms)
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] downloading http://repo.rwe.com:8080/nexus/content/groups/public/org/scalameta/semanticdb-scalac_2.12.8/4.1.4/semanticdb-scalac_2.12.8-4.1.4-sources.jar ...
[info]  [SUCCESSFUL ] org.scalameta#semanticdb-scalac_2.12.8;4.1.4!semanticdb-scalac_2.12.8.jar(src) (187ms)
[success] Generated .bloop\root-test.json
[success] Generated .bloop\root.json
[success] Total time: 187 s, completed 11.03.2019 14:09:30

Thanks. Could it be that NuProcess (library we use to run system processes) has problems on Windows 7? I don't know much about Windows 7, but I know NuProcess uses native libraries that caused problems on FreeBSD.

when opening vscode now I get this error

Import project partially failed, limited functionality may work in some parts of the workspace. See the logs for more details. 

and this in my metals.log

java.lang.RuntimeException: CreateProcessW() failed, error: 193
    at com.zaxxer.nuprocess.windows.WindowsProcess.start(WindowsProcess.java:248)
    at com.zaxxer.nuprocess.windows.WinProcessFactory.createProcess(WinProcessFactory.java:42)
    at com.zaxxer.nuprocess.NuProcessBuilder.start(NuProcessBuilder.java:266)
    at scala.meta.internal.metals.BloopInstall.runArgumentsUnconditionally(BloopInstall.scala:103)
    at scala.meta.internal.metals.BloopInstall.runUnconditionally(BloopInstall.scala:80)
    at scala.meta.internal.metals.BloopInstall.$anonfun$runIfApproved$2(BloopInstall.scala:157)
    at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
    at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
    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)
...
The server is listening for incoming connections at tcp://127.0.0.1:64096...
The server is listening for incoming connections at tcp://127.0.0.1:64094...
The server is listening for incoming connections at tcp://127.0.0.1:64128...
Accepted incoming BSP client connection at tcp://127.0.0.1:64094
Accepted incoming BSP client connection at tcp://127.0.0.1:64128
request received: build/initialize
BSP initialization handshake complete.
request received: build/initialize
BSP initialization handshake complete.
cal\scalameta\metals\cache\bsp.trace.json
INFO  time: connected to build server in 54s
INFO  tracing is disabled for protocol BSP, to enable tracing of incoming and outgoing JSON messages create an empty file at C:\Users\r892107\AppData\Local\scalameta\metals\cache\bsp.trace.json
INFO  time: connected to build server in 52s
INFO  time: imported build in 3.94s
INFO  time: imported build in 4.7s
INFO  time: indexed workspace in 4.93s
INFO  time: indexed workspace in 9.41s
INFO  compiling root (58 scala sources)
INFO  compiling root (58 scala sources)
INFO  Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.8. Compiling...
INFO    Compilation completed in 27.823s.
INFO  time: compiled root in 2m19s
INFO  time: compiled root in 2m19s
INFO  compiling root-test (29 scala sources)
INFO  time: compiled root-test in 28s

where it does download hundreds of dependencies in ... above.

after another restart of vscode I do not see any error and functionality seems to work (Go to Definition)

after removing the .bloop and .metals directory I am back at the initial error.
Which version of NuProcess are you using? There are only some issues related to CreateProcessW in NuProcess issue tracker.

We are on nuprocess 1.2.4, which looks like the latest https://mvnrepository.com/artifact/com.zaxxer/nuprocess

A workaround is to manually run the following from the console

METALS_ENABLED=true sbt metalsEnable bloopInstall

This step needs to run every time the build changes or when you remove the .bloop directory.

When Metals asks to "Import changes" you can select "Don't show again" to dismiss those questions in the future. We rely on NuProcess because it allows us to expose a Future[Int] for the sbt process, which I couldn't figure out how to do with java.lang.ProcessBuilder.

@mrt181 have you been able to reproduce this issue on another computer? I'm not sure what we can do to fix this issue. I am unable to reproduce and we test every pull request on a Windows Server 2012.

Please reopen if you are able to provide a reproduction.

this error is gone since 0.5.0

Trying to Import build:

INFO  time: initialize in 0.25s
INFO  running '/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java -Djline.terminal=jline.UnsupportedTerminal -Dsbt.log.noformat=true -Dfile.encoding=UTF-8 -jar /tmp/metals3576706053101751697/sbt-launch.jar metalsEnable bloopInstall'
Aug 08, 2019 1:27:11 PM com.zaxxer.nuprocess.linux.LinuxProcess start
WARNING: Failed to start process
java.io.IOException: error=20, Not a directory
    at com.zaxxer.nuprocess.internal.LibJava8.Java_java_lang_UNIXProcess_forkAndExec(Native Method)
    at com.zaxxer.nuprocess.linux.LinuxProcess.start(LinuxProcess.java:109)
    at com.zaxxer.nuprocess.linux.LinProcessFactory.createProcess(LinProcessFactory.java:40)
    at com.zaxxer.nuprocess.NuProcessBuilder.start(NuProcessBuilder.java:266)
    at scala.meta.internal.metals.BloopInstall.runArgumentsUnconditionally(BloopInstall.scala:80)
    at scala.meta.internal.metals.BloopInstall.runUnconditionally(BloopInstall.scala:55)
    at scala.meta.internal.metals.BloopInstall.$anonfun$runIfApproved$2(BloopInstall.scala:151)
    at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
    at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
    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)

INFO  build tool exit: -2147483648
INFO  time: ran 'sbt bloopInstall' in 86ms
ERROR sbt command failed: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java -Djline.terminal=jline.UnsupportedTerminal -Dsbt.log.noformat=true -Dfile.encoding=UTF-8 -jar /tmp/metals3576706053101751697/sbt-launch.jar metalsEnable bloopInstall

Reproduced today with this conditions:

  • sbt new scala/scala-seed.g8
  • java-8-openjdk-amd64
  • 18.04.1-Ubuntu
  • vscode-1.36.1
  • metals-1.5.2
  • sbt-1.2.8

After running command (METALS_ENABLED=true sbt metalsEnable bloopInstall) mentioned by @olafurpg all works as expected.

Looks like it detected /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java/bin/java as the path to Java - that's pretty weird. You can specify the java home inside metals settings and it should later work properly. It seems to work on my machine with a similar setup and same java version.

Thanks, @tgodzik, you are right, JAVA_HOME in my system was not quite correct. I changed this one to /usr/lib/jvm/java-1.8.0-openjdk-amd64 and metals works out of the box.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

m4dc4p picture m4dc4p  Â·  4Comments

iokacha picture iokacha  Â·  4Comments

laughedelic picture laughedelic  Â·  4Comments

fommil picture fommil  Â·  3Comments

olafurpg picture olafurpg  Â·  4Comments