Metals: VS Code extension on windows initially fails to connect to bloop

Created on 10 Apr 2020  路  11Comments  路  Source: scalameta/metals

Describe the bug
After applying a fix for https://github.com/scalameta/metals/issues/1600 by setting the mill path to a fixed wrapper, an initial attempt to connect to the server fails. A subsequent attempt succeeds and everything seems to work fine but the user is prompted with a warning notification about limited functionality.

To Reproduce
Steps to reproduce the behavior:

  1. Create a mill project
  2. Open folder containing project in VS Code
  3. Run Metals: Import build
  4. Check output
  5. Check notification area

Expected behavior
No warning is shown, build server successfully connects the first time.

Screenshots
Notification area gives:

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

Output gives:

INFO  [148/148] mill.contrib.bloop.BloopImpl.install 
INFO  Failed to connect to server
INFO  build tool exit: 1
INFO  time: ran 'mill bloopInstall' in 1.17s
ERROR Mill command failed: C:\Users\NATHAN~1\AppData\Local\Temp\metals81364211047803705\millw.bat --predef C:\Users\NATHAN~1\AppData\Local\Temp\metals9998593126039946172\predef.sc mill.contrib.Bloop/install
INFO  disconnected: build server
INFO  tracing is disabled for protocol BSP, to enable tracing of incoming and outgoing JSON messages create an empty file at C:\Users\Nathan Fischer\AppData\Local\scalameta\metals\cache\bsp.trace.json
INFO  time: connected to build server in 0.76s
INFO  Connected to Build server v1.4.0-RC1-105-118a551b
INFO  time: imported build in 0.14s
INFO  time: indexed workspace in 3.34s

Installation:

  • Operating system: Windows 10
  • Editor: Visual Studio Code
  • Metals (extension) version: 1.8.6

Additional context
Running the command (C:\Users\NATHAN~1\AppData\Local\Temp\metals81364211047803705\millw.bat --predef C:\Users\NATHAN~1\AppData\Local\Temp\metals9998593126039946172\predef.sc mill.contrib.Bloop/install) directly in the command prompt works fine, no messages about connecting to the build server are shown.

Search terms
mill vs code bloop warning

needs more information

Most helpful comment

I cannot confirm that it fails on 0.9.0 because of the error Cannot resolve --mill-version. Trymill resolve _to see what's available. (confused to why that would appear when it runs the millw.bat wrapper), but for the snapshot version it seems to work fine:

Java home: C:\Users\ginnu\scoop\apps\openjdk11\current
2020.05.18 13:17:28 INFO  logging to file C:\Users\ginnu\Source\tmp\example-1\.metals\metals.log
2020.05.18 13:17:28 INFO  started: Metals version 0.9.0+87-bab412a2-SNAPSHOT in workspace 'C:\Users\ginnu\Source\tmp\example-1'
2020.05.18 13:17:30 INFO  time: initialize in 1.58s
Initializing Scala Debugger
2020.05.18 13:17:32 INFO  no build target: using presentation compiler with only scala-library
2020.05.18 13:17:35 INFO  running 'C:\Users\ginnu\AppData\Local\Temp\metals16507158730204726139\millw.bat --mill-version 0.6.2 -i --predef C:\Users\ginnu\AppData\Local\Temp\metals16507158730204726139\predef.sc mill.contrib.Bloop/install'
2020.05.18 13:18:47 INFO  Compiling C:\Users\ginnu\AppData\Local\Temp\metals16507158730204726139\predef.sc
2020.05.18 13:18:56 INFO  Compiling C:\Users\ginnu\Source\tmp\example-1\build.sc
2020.05.18 13:19:00 INFO  [1/23] foo.sources 
2020.05.18 13:19:00 INFO  [2/23] foo.generatedSources 
2020.05.18 13:19:00 INFO  [3/23] foo.allSources 
2020.05.18 13:19:00 INFO  [4/23] mill.contrib.bloop.BloopImpl.moduleSourceMap 
2020.05.18 13:19:00 INFO  [5/23] foo.unmanagedClasspath 
2020.05.18 13:19:00 INFO  [6/23] foo.scalaVersion 
2020.05.18 13:19:00 INFO  [7/23] foo.platformSuffix 
2020.05.18 13:19:00 INFO  [8/23] foo.compileIvyDeps 
2020.05.18 13:19:00 INFO  [9/23] foo.ivyDeps 
2020.05.18 13:19:00 INFO  [10/23] foo.transitiveIvyDeps 
2020.05.18 13:19:00 INFO  [11/23] foo.scalaOrganization 
2020.05.18 13:19:00 INFO  [12/23] foo.scalaLibraryIvyDeps 
2020.05.18 13:19:00 INFO  [13/23] foo.resources 
2020.05.18 13:19:00 INFO  [14/23] foo.scalacPluginIvyDeps 
2020.05.18 13:19:00 INFO  [15/23] foo.scalacPluginClasspath 
2020.05.18 13:19:00 INFO  [16/23] foo.scalacOptions 
2020.05.18 13:19:00 INFO  [17/23] foo.scalaCompilerClasspath 
2020.05.18 13:19:01 INFO  [18/23] foo.javacOptions 
2020.05.18 13:19:01 INFO  [19/23] foo.forkArgs 
2020.05.18 13:19:01 INFO  [20/23] foo.mainClass 
2020.05.18 13:19:01 INFO  [21/23] foo.bloop.config 
2020.05.18 13:19:01 INFO  [22/23] foo.bloop.writeConfig 
2020.05.18 13:19:01 INFO  Wrote C:\Users\ginnu\Source\tmp\example-1\.bloop\foo.json
2020.05.18 13:19:01 INFO  [23/23] mill.contrib.bloop.BloopImpl.install 
2020.05.18 13:19:01 INFO  build tool exit: 0
2020.05.18 13:19:01 INFO  time: ran 'mill bloopInstall' in 1m26s
2020.05.18 13:19:02 INFO  tracing is disabled for protocol BSP, to enable tracing of incoming and outgoing JSON messages create an empty file at C:\Users\ginnu\AppData\Local\scalameta\metals\cache\bsp.trace.json
2020.05.18 13:19:02 INFO  time: connected to build server in 0.71s
2020.05.18 13:19:02 INFO  Connected to Build server v1.4.0-RC1-235-3231567a
2020.05.18 13:19:05 INFO  time: indexed workspace in 2.67s

Works fine on another project I am working on as well.

All 11 comments

Thanks for reporting! The warning is displayed, because the mill import command fails:
ERROR Mill command failed: C:\Users\NATHAN~1\AppData\Local\Temp\metals81364211047803705\millw.bat --predef C:\Users\NATHAN~1\AppData\Local\Temp\metals9998593126039946172\predef.sc mill.contrib.Bloop/install

Is there any more data in the output about why it failed?

Unfortunately not, only INFO build tool exit: 1.

The only hint we have is that the command is able to run to a successful exit in the command prompt, but not when executed by the plugin.

I wonder if it might be that in both cases the exit code is actually non zero, but only breaks in Metals? Would it be possible to check?

I will try to run a mill windows slow test, might show some other issues.

%errorlevel% indicates exit code is 0 from the command prompt.

Testing the integration here: https://github.com/scalameta/metals/pull/1632

On Windows, you will get an error code from mill because the default wrapper do not use the -i option and the socket code mill uses for Windows is broken. I use my own wrapper for mill that forces the -i option and have not had the described issue since.

@heksesang @kag0 I think this should be fixed in https://github.com/scalameta/metals/pull/1715 We now automatically add -i option on windows for the embedded mill script. This should work in latest snapshot

Could you confirm?

I cannot confirm that it fails on 0.9.0 because of the error Cannot resolve --mill-version. Trymill resolve _to see what's available. (confused to why that would appear when it runs the millw.bat wrapper), but for the snapshot version it seems to work fine:

Java home: C:\Users\ginnu\scoop\apps\openjdk11\current
2020.05.18 13:17:28 INFO  logging to file C:\Users\ginnu\Source\tmp\example-1\.metals\metals.log
2020.05.18 13:17:28 INFO  started: Metals version 0.9.0+87-bab412a2-SNAPSHOT in workspace 'C:\Users\ginnu\Source\tmp\example-1'
2020.05.18 13:17:30 INFO  time: initialize in 1.58s
Initializing Scala Debugger
2020.05.18 13:17:32 INFO  no build target: using presentation compiler with only scala-library
2020.05.18 13:17:35 INFO  running 'C:\Users\ginnu\AppData\Local\Temp\metals16507158730204726139\millw.bat --mill-version 0.6.2 -i --predef C:\Users\ginnu\AppData\Local\Temp\metals16507158730204726139\predef.sc mill.contrib.Bloop/install'
2020.05.18 13:18:47 INFO  Compiling C:\Users\ginnu\AppData\Local\Temp\metals16507158730204726139\predef.sc
2020.05.18 13:18:56 INFO  Compiling C:\Users\ginnu\Source\tmp\example-1\build.sc
2020.05.18 13:19:00 INFO  [1/23] foo.sources 
2020.05.18 13:19:00 INFO  [2/23] foo.generatedSources 
2020.05.18 13:19:00 INFO  [3/23] foo.allSources 
2020.05.18 13:19:00 INFO  [4/23] mill.contrib.bloop.BloopImpl.moduleSourceMap 
2020.05.18 13:19:00 INFO  [5/23] foo.unmanagedClasspath 
2020.05.18 13:19:00 INFO  [6/23] foo.scalaVersion 
2020.05.18 13:19:00 INFO  [7/23] foo.platformSuffix 
2020.05.18 13:19:00 INFO  [8/23] foo.compileIvyDeps 
2020.05.18 13:19:00 INFO  [9/23] foo.ivyDeps 
2020.05.18 13:19:00 INFO  [10/23] foo.transitiveIvyDeps 
2020.05.18 13:19:00 INFO  [11/23] foo.scalaOrganization 
2020.05.18 13:19:00 INFO  [12/23] foo.scalaLibraryIvyDeps 
2020.05.18 13:19:00 INFO  [13/23] foo.resources 
2020.05.18 13:19:00 INFO  [14/23] foo.scalacPluginIvyDeps 
2020.05.18 13:19:00 INFO  [15/23] foo.scalacPluginClasspath 
2020.05.18 13:19:00 INFO  [16/23] foo.scalacOptions 
2020.05.18 13:19:00 INFO  [17/23] foo.scalaCompilerClasspath 
2020.05.18 13:19:01 INFO  [18/23] foo.javacOptions 
2020.05.18 13:19:01 INFO  [19/23] foo.forkArgs 
2020.05.18 13:19:01 INFO  [20/23] foo.mainClass 
2020.05.18 13:19:01 INFO  [21/23] foo.bloop.config 
2020.05.18 13:19:01 INFO  [22/23] foo.bloop.writeConfig 
2020.05.18 13:19:01 INFO  Wrote C:\Users\ginnu\Source\tmp\example-1\.bloop\foo.json
2020.05.18 13:19:01 INFO  [23/23] mill.contrib.bloop.BloopImpl.install 
2020.05.18 13:19:01 INFO  build tool exit: 0
2020.05.18 13:19:01 INFO  time: ran 'mill bloopInstall' in 1m26s
2020.05.18 13:19:02 INFO  tracing is disabled for protocol BSP, to enable tracing of incoming and outgoing JSON messages create an empty file at C:\Users\ginnu\AppData\Local\scalameta\metals\cache\bsp.trace.json
2020.05.18 13:19:02 INFO  time: connected to build server in 0.71s
2020.05.18 13:19:02 INFO  Connected to Build server v1.4.0-RC1-235-3231567a
2020.05.18 13:19:05 INFO  time: indexed workspace in 2.67s

Works fine on another project I am working on as well.

@heksesang Thanks!

Snapshot works for me!
I also get the error from --mill-version with the default wrapper script on 0.9.0 fwiw.

Thanks! Closing it, since the fix is confirmed.

Was this page helpful?
0 / 5 - 0 ratings