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

Importing projects fails on VSCode and IntelliJ on Windows #4161

Open
UtilFunction opened this issue Dec 18, 2024 · 9 comments
Open

Importing projects fails on VSCode and IntelliJ on Windows #4161

UtilFunction opened this issue Dec 18, 2024 · 9 comments

Comments

@UtilFunction
Copy link

Steps to reproduce:

  1. Download sample project
  2. Import on IntelliJ or VSCode

IntelliJ Error:

Executing C:\Users\user\project\sc\mill.bat -i mill.bsp.BSP/install
 
                                                                                 
	at io.github.alexarchambault.windowsansi.WindowsAnsi.setup(WindowsAnsi.java:34)
	at mill.runner.MillMain$.$anonfun$main$1(MillMain.scala:72)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
	at mill.api.SystemStreams$.withTopLevelSystemStreamProxy(SystemStreams.scala:125)
	at mill.runner.MillMain$.main(MillMain.scala:41)
	at mill.runner.MillMain.main(MillMain.scala)

VSCode Error:

2024.12.18 08:58:45 ERROR Mill command failed: C:\Users\user\project\sc\.metals\millw.bat -i --import ivy:com.lihaoyi::mill-contrib-bloop: mill.contrib.bloop.Bloop/install
2024.12.18 08:58:52 INFO  running 'C:\Users\user\project\sc\.metals\millw.bat -i --import ivy:com.lihaoyi::mill-contrib-bloop: mill.contrib.bloop.Bloop/install'
2024.12.18 08:58:53 INFO  Exception in thread "main" java.io.IOException: Failed to get console mode: D e r   V o r g a n g   w u r d e   e r f o l g r e i c h   b e e n d e t . 
2024.12.18 08:58:53 INFO   
2024.12.18 08:58:53 INFO                                                                                   
2024.12.18 08:58:53 INFO  	at io.github.alexarchambault.windowsansi.WindowsAnsi.setup(WindowsAnsi.java:34)
2024.12.18 08:58:53 INFO  	at mill.runner.MillMain$.$anonfun$main$1(MillMain.scala:72)
2024.12.18 08:58:53 INFO  	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
2024.12.18 08:58:53 INFO  	at mill.api.SystemStreams$.withTopLevelSystemStreamProxy(SystemStreams.scala:125)
2024.12.18 08:58:53 INFO  	at mill.runner.MillMain$.main(MillMain.scala:41)
2024.12.18 08:58:53 INFO  	at mill.runner.MillMain.main(MillMain.scala)
2024.12.18 08:58:52 INFO  time: ran 'mill bloopInstall' in 0.53s
2024.12.18 08:58:53 ERROR Mill command failed: C:\Users\user\project\sc\.metals\millw.bat -i --import ivy:com.lihaoyi::mill-contrib-bloop: mill.contrib.bloop.Bloop/install

Windows 11 24H2
OpenJDK 23.0.1
Metals 1.44.0
IntelliJ 2024.3 (Scala Plugin ver. 2024.3.574)
Mill 0.12.4

@lihaoyi
Copy link
Member

lihaoyi commented Dec 18, 2024

@UtilFunction are you on ARM windows? I wonder if it's related to #4055

@UtilFunction
Copy link
Author

@lihaoyi no, x64.

@UtilFunction
Copy link
Author

@lihaoyi strangely it works if I set the absolute path in the VSCode Metals settings and point it to "C:\Users\user\project\sc\.metals\millw.bat"

@lihaoyi
Copy link
Member

lihaoyi commented Dec 18, 2024

@UtilFunction that's a bit unusual, i thought i merged millw.bat into mill.bat recently, so they should be the same. Could you compare both files and see if they are indeed the same?

@UtilFunction
Copy link
Author

@lihaoyi this is the only difference between the files:
Code_0VHOTTyotc

@lihaoyi
Copy link
Member

lihaoyi commented Dec 18, 2024

@UtilFunction got it, looks like it's the same then. I don't have my windows laptop with me now but I can try next time I have it

@alexarchambault
Copy link
Contributor

alexarchambault commented Dec 18, 2024

Maybe that error could be silently trapped, or reported, but then ignored by Mill. That call is meant to enable ANSI output in windows terminals. It's only a nice-to-have, it shouldn't make Mill crash.

@UtilFunction
Copy link
Author

Update:
It seems to work with JDK 21.0.5+11 but not with 23.0.1+11.

@nartamonov
Copy link

nartamonov commented Dec 23, 2024

I have the same problem. It only occurs when importing BSP project by IntelliJ IDEA. Current workaround: create file .mill-jvm-opts in the project root with the following content:

-Djdk.console=java.base

It seems to me that this is a bug in the alexarchambault/windows-ansi library, which is not compatible with the latest changes in JDK. In particular, JDK has changed the behavior of the method System.console():

In JDK 22, System.console() has been changed to return a Console with enhanced editing features that improve the experience of programs that use the Console API. In addition, System.console() now returns a Console object when the standard streams are redirected or connected to a virtual terminal. Prior to JDK 22, System.console() instead returned null for these cases. This change may impact code that checks the return from System.console() to test if the JVM is connected to a terminal. If required, the -Djdk.console=java.base flag will restore the old behavior where the console is only returned when it is connected to a terminal. Starting JDK 22, one could also use the new Console.isTerminal() method to test if the console is connected to a terminal.

Maybe I'm wrong, not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants