-
Notifications
You must be signed in to change notification settings - Fork 139
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
scala-cli -e 'println("hello")' > /dev/null throws java.io.IOException #3481
Comments
java.io.IOException: Error enabling ANSI output: GetConsoleMode error 6
This may be related. When piping the output rather than redirecting, hello.sc | /dev/null
Compiling project (Scala 3.6.3, JVM (17))
Compiled project (Scala 3.6.3, JVM (17))
[E] Exiting BSP server with Connection reset
Bloop 'bsp' command exited with code 1. Something may be wrong with the current configuration.
Running the clean sub-command to clear the working directory and remove caches might help.
If the error persists, please report the issue as a bug and attach a log with increased verbosity by passing -v -v -v. |
I assume that @tgodzik is notified when he is mentioned like this. I thought so [that it's Windows-specific] because I didn't see the problem when I did a quick check in a WSL bash session. This is apparently not a Windows-only problem, although it doesn't manifest in exactly the same way. In Windows Terminal I get this:
See below for the WSL bash session crash and stacktrace. |
Turns out that it also crashes in a Linux bash session, and even with a valid command line: :/opt/ue$ clisrc/hello.sc > /dev/null
[E] Caught bloop.data.Project$ProjectReadException: Failed to load project from /opt/ue/clisrc/.scala-build/.bloop/clisrc_eac7d69449-afeaabc44b.json
Bloop 'bsp' command exited with code 1. Something may be wrong with the current configuration.
Running the clean sub-command to clear the working directory and remove caches might help.
If the error persists, please report the issue as a bug and attach a log with increased verbosity by passing -v -v -v.
Error: java.lang.RuntimeException: Bloop BSP connection in /home/philwalk/.cache/scalacli/bsp-sockets/proc-340 was unexpectedly closed or bloop didn't start.
For more details, please see '/opt/ue/clisrc/.scala-build/stacktraces/1739284966-4775558018048031860.log'
(base) philwalk@d5:/opt/ue$ Here's the stacktrace:
|
More info on Windows/Linux versions of the problem: scala -e "println("""hello""")" > /dev/null And also in a It's not problem when STDOUT is not redirected, or is redirected to a file C:\Windows\System32>scala-cli.exe -e "println("""hello""")"
Compiling project (Scala 3.6.3, JVM (11))
Compiled project (Scala 3.6.3, JVM (11))
hello
C:\Windows\System32>scala-cli.exe -e "println("""hello""")" > s0
Compiling project (Scala 3.6.3, JVM (11))
Compiled project (Scala 3.6.3, JVM (11))
C:\Windows\System32>type s0
hello The problem occurs when redirecting to C:\Windows\System32>scala-cli.exe -e "println("""hello""")" > NUL
Error: java.io.IOException: Error enabling ANSI output: GetConsoleMode error 6
For more details, please see 'C:\Windows\System32\.scala-build\stacktraces\1739296010-9469441151690933143.log'
C:\Windows\System32>type C:\Windows\System32\.scala-build\stacktraces\1739296010-9469441151690933143.log
java.io.IOException: Error enabling ANSI output: GetConsoleMode error 6
coursier.jniutils.WindowsAnsiTerminal.enableAnsiOutput(WindowsAnsiTerminal.java:25)
scala.cli.ScalaCli$.main0(ScalaCli.scala:317)
scala.cli.ScalaCli$.main(ScalaCli.scala:124)
scala.cli.ScalaCli.main(ScalaCli.scala) Unable to reproduce the problem in WSL Ubuntu with this particular command line: (base) philwalk@d5:~$ scala -e "println(\"hello\")"
Compiling project (Scala 3.6.3, JVM (17))
Compiled project (Scala 3.6.3, JVM (17))
hello However, in WSL there's a #!/usr/bin/env -S scala-cli shebang
//> using scala 3.4.3
printf("scriptPath: [%s]\n", scriptPath)
sys.props("java.class.path").split(psep).foreach { println }
def psep: String = sys.props("path.separator") (base) philwalk@d5:/opt/ue$ clisrc/hello.sc
Starting compilation server
[E] Caught bloop.data.Project$ProjectReadException: Failed to load project from /opt/ue/clisrc/.scala-build/.bloop/clisrc_eac7d69449-afeaabc44b.json
Bloop 'bsp' command exited with code 1. Something may be wrong with the current configuration.
Running the clean sub-command to clear the working directory and remove caches might help.
If the error persists, please report the issue as a bug and attach a log with increased verbosity by passing -v -v -v.
Error: java.lang.RuntimeException: Bloop BSP connection in /home/philwalk/.cache/scalacli/bsp-sockets/proc-1864 was unexpectedly closed or bloop didn't start.
For more details, please see '/opt/ue/clisrc/.scala-build/stacktraces/1739296852-7851145895565982827.log'
(base) philwalk@d5:/opt/ue$
(base) philwalk@d5:/opt/ue$ cat '/opt/ue/clisrc/.scala-build/stacktraces/1739296852-7851145895565982827.log'
java.lang.RuntimeException: Bloop BSP connection in /home/philwalk/.cache/scalacli/bsp-sockets/proc-1864 was unexpectedly closed or bloop didn't start.
scala.sys.package$.error(package.scala:27)
bloop.rifle.internal.Operations$$anon$1.openSocket(Operations.scala:426)
bloop.rifle.BloopServer$.create$1(BloopServer.scala:128)
bloop.rifle.BloopServer$.connect(BloopServer.scala:144)
bloop.rifle.BloopServer$.bsp(BloopServer.scala:167)
bloop.rifle.BloopServer$.buildServer(BloopServer.scala:186)
scala.build.compiler.BloopCompilerMaker.$anonfun$1(BloopCompilerMaker.scala:48)
scala.build.compiler.BloopCompiler.<init>(BloopCompiler.scala:15)
scala.build.compiler.BloopCompilerMaker.$anonfun$2(BloopCompilerMaker.scala:51)
scala.util.Try$.apply(Try.scala:217)
scala.build.compiler.BloopCompilerMaker.create(BloopCompilerMaker.scala:51)
scala.build.compiler.ScalaCompilerMaker.withCompiler(ScalaCompilerMaker.scala:34)
scala.build.compiler.ScalaCompilerMaker.withCompiler$(ScalaCompilerMaker.scala:9)
scala.build.compiler.BloopCompilerMaker.withCompiler(BloopCompilerMaker.scala:14)
scala.build.Build$.build$$anonfun$3(Build.scala:611)
scala.build.EitherCps$Helper.apply(EitherCps.scala:19)
scala.build.Build$.build(Build.scala:596)
scala.cli.commands.run.Run$.runCommand(Run.scala:334)
scala.cli.commands.shebang.Shebang$.runCommand(Shebang.scala:33)
scala.cli.commands.shebang.Shebang$.runCommand(Shebang.scala:26)
scala.cli.commands.ScalaCommand.run(ScalaCommand.scala:401)
scala.cli.commands.ScalaCommand.run(ScalaCommand.scala:382)
caseapp.core.app.CaseApp.main(CaseApp.scala:166)
scala.cli.commands.ScalaCommand.main(ScalaCommand.scala:367)
caseapp.core.app.CommandsEntryPoint.main(CommandsEntryPoint.scala:370)
scala.cli.ScalaCliCommands.main(ScalaCliCommands.scala:125)
scala.cli.ScalaCli$.main0(ScalaCli.scala:320)
scala.cli.ScalaCli$.main(ScalaCli.scala:124)
scala.cli.ScalaCli.main(ScalaCli.scala) This one clears up after doing
|
Version(s)
# scala-cli --version Scala CLI version: 1.6.1 Scala version (default): 3.6.3
Describe the bug
Redirecting stdout to /dev/null throws an Exception.
To Reproduce
hello.sc:
Should not throw an exception.
The text was updated successfully, but these errors were encountered: