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

Can't compile with scala-cli #2573

Open
odersky opened this issue Jan 15, 2025 · 2 comments
Open

Can't compile with scala-cli #2573

odersky opened this issue Jan 15, 2025 · 2 comments
Milestone

Comments

@odersky
Copy link

odersky commented Jan 15, 2025

I have a simple Scala file in tests/new/test.scala

class Test {
}

When I try to compile this with scala-cli I get a crash.

Reported scala-cli version

Scala CLI version: 1.5.4
Scala version (default): 3.5.2

Stacktrace:

~/workspace/dotty> scala compile tests/new/test.scala -v -v -v
Warning: Only java properties are supported in JAVA_OPTS and JDK_JAVA_OPTIONS environment variables. Other options are ignored: -Xmx4000m, -Xms256m
Checking for a running Bloop server at /Users/odersky/Library/Caches/ScalaCli/bloop/daemon ...
Attempting to connect to Bloop server /Users/odersky/Library/Caches/ScalaCli/bloop/daemon ...
Connection attempt result: Some(Right(java.nio.channels.SocketChannel[connected local= remote=/Users/odersky/Library/Caches/ScalaCli/bloop/daemon/socket]))
nailgun debug: Sending arguments '' to Nailgun server
nailgun debug: Sending environment variables to Nailgun server
nailgun debug: Sending working directory /Users/odersky/workspace/dotty to Nailgun server
nailgun debug: Sending command to about Nailgun server
nailgun debug: Finished sending command information to Nailgun server
nailgun debug: Starting thread to read stdin...
nailgun debug: Received action Print([B@55143f77) from Nailgun server
nailgun debug: Received action Print([B@e0db31) from Nailgun server
nailgun debug: Received action Print([B@ce35194) from Nailgun server
nailgun debug: Received action Print([B@759b3c47) from Nailgun server
nailgun debug: Received action Print([B@1512e392) from Nailgun server
nailgun debug: Received action Print([B@3a180f4f) from Nailgun server
nailgun debug: Received action Exit(0) from Nailgun server
nailgun debug: Waiting for stdin thread to finish...
nailgun debug: Waiting for heartbeat thread to finish...
nailgun debug: Returning exit code...
Checking for a running Bloop server at /Users/odersky/Library/Caches/ScalaCli/bloop/daemon ...
Attempting to connect to Bloop server /Users/odersky/Library/Caches/ScalaCli/bloop/daemon ...
Connection attempt result: Some(Right(java.nio.channels.SocketChannel[connected local= remote=/Users/odersky/Library/Caches/ScalaCli/bloop/daemon/socket]))
Checking for a running Bloop server at /Users/odersky/Library/Caches/ScalaCli/bloop/daemon ...
Attempting to connect to Bloop server /Users/odersky/Library/Caches/ScalaCli/bloop/daemon ...
Connection attempt result: Some(Right(java.nio.channels.SocketChannel[connected local= remote=/Users/odersky/Library/Caches/ScalaCli/bloop/daemon/socket]))
nailgun debug: Sending arguments '' to Nailgun server
nailgun debug: Sending environment variables to Nailgun server
nailgun debug: Sending working directory /Users/odersky/workspace/dotty to Nailgun server
nailgun debug: Sending command to about Nailgun server
nailgun debug: Finished sending command information to Nailgun server
nailgun debug: Starting thread to read stdin...
nailgun debug: Received action Print([B@6981651e) from Nailgun server
nailgun debug: Received action Print([B@4d677565) from Nailgun server
nailgun debug: Received action Print([B@2f3cbd85) from Nailgun server
nailgun debug: Received action Print([B@5eb2021e) from Nailgun server
nailgun debug: Received action Print([B@3149d25e) from Nailgun server
nailgun debug: Received action Print([B@4e98427c) from Nailgun server
nailgun debug: Received action Exit(0) from Nailgun server
nailgun debug: Waiting for stdin thread to finish...
nailgun debug: Waiting for heartbeat thread to finish...
nailgun debug: Returning exit code...
Opening BSP connection with bloop
Bloop BSP connection waiting at local:/Users/odersky/Library/Caches/ScalaCli/bsp-sockets/proc-81719
nailgun debug: Sending arguments '--protocol local --socket /Users/odersky/Library/Caches/ScalaCli/bsp-sockets/proc-81719' to Nailgun server
nailgun debug: Sending environment variables to Nailgun server
nailgun debug: Sending working directory /Users/odersky/workspace/dotty/tests/new/.scala-build to Nailgun server
nailgun debug: Sending command to bsp Nailgun server
nailgun debug: Finished sending command information to Nailgun server
nailgun debug: Starting thread to read stdin...
BSP connection at /Users/odersky/Library/Caches/ScalaCli/bsp-sockets/proc-81719 not found, waiting 100 milliseconds
nailgun debug: Received action Print([B@49ca86ac) from Nailgun server
[W] Scala instance jar /Users/odersky/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/3.3.1/scala3-compiler_3-3.3.1.jar doesn't exist!
nailgun debug: Received action Print([B@7b92d85c) from Nailgun server
[W] Scala instance jar /Users/odersky/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-interfaces/3.3.1/scala3-interfaces-3.3.1.jar doesn't exist!
nailgun debug: Received action Print([B@59848bf7) from Nailgun server
[W] Scala instance jar /Users/odersky/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.3.1/scala3-library_3-3.3.1.jar doesn't exist!
nailgun debug: Received action Print([B@7c6e8c58) from Nailgun server
[W] Scala instance jar /Users/odersky/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/tasty-core_3/3.3.1/tasty-core_3-3.3.1.jar doesn't exist!
nailgun debug: Received action Print([B@23fd7bf2) from Nailgun server
[W] Scala instance jar /Users/odersky/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/3.3.1/scala3-compiler_3-3.3.1.jar doesn't exist!
nailgun debug: Received action Print([B@403c5505) from Nailgun server
[W] Scala instance jar /Users/odersky/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-interfaces/3.3.1/scala3-interfaces-3.3.1.jar doesn't exist!
nailgun debug: Received action Print([B@129fe79e) from Nailgun server
[W] Scala instance jar /Users/odersky/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.3.1/scala3-library_3-3.3.1.jar doesn't exist!
nailgun debug: Received action Print([B@77cca303) from Nailgun server
[W] Scala instance jar /Users/odersky/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/tasty-core_3/3.3.1/tasty-core_3-3.3.1.jar doesn't exist!
nailgun debug: Received action Print([B@4daf9d61) from Nailgun server
[E] Caught bloop.data.Project$ProjectReadException: Failed to load project from /Users/odersky/workspace/dotty/tests/new/.scala-build/.bloop/new_103be31561-e70f52769f.json
nailgun debug: Received action Exit(1) from Nailgun server
nailgun debug: Waiting for stdin thread to finish...
nailgun debug: Waiting for heartbeat thread to finish...
nailgun debug: Returning exit code...
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.
Exception in thread "main" java.lang.RuntimeException: Bloop BSP connection in /Users/odersky/Library/Caches/ScalaCli/bsp-sockets/proc-81719 was unexpectedly closed or bloop didn't start.
	at scala.sys.package$.error(package.scala:27)
	at bloop.rifle.internal.Operations$$anon$1.openSocket(Operations.scala:422)
	at bloop.rifle.BloopServer$.create$1(BloopServer.scala:128)
	at bloop.rifle.BloopServer$.connect(BloopServer.scala:144)
	at bloop.rifle.BloopServer$.bsp(BloopServer.scala:167)
	at bloop.rifle.BloopServer$.buildServer(BloopServer.scala:186)
	at scala.build.compiler.BloopCompilerMaker.$anonfun$1(BloopCompilerMaker.scala:48)
	at scala.build.compiler.BloopCompiler.<init>(BloopCompiler.scala:15)
	at scala.build.compiler.BloopCompilerMaker.$anonfun$2(BloopCompilerMaker.scala:51)
	at scala.util.Try$.apply(Try.scala:217)
	at scala.build.compiler.BloopCompilerMaker.create(BloopCompilerMaker.scala:51)
	at scala.build.compiler.ScalaCompilerMaker.withCompiler(ScalaCompilerMaker.scala:34)
	at scala.build.compiler.ScalaCompilerMaker.withCompiler$(ScalaCompilerMaker.scala:9)
	at scala.build.compiler.BloopCompilerMaker.withCompiler(BloopCompilerMaker.scala:14)
	at scala.build.Build$.build$$anonfun$3(Build.scala:611)
	at scala.build.EitherCps$Helper.apply(EitherCps.scala:19)
	at scala.build.Build$.build(Build.scala:596)
	at scala.cli.commands.compile.Compile$.runCommand(Compile.scala:134)
	at scala.cli.commands.compile.Compile$.runCommand(Compile.scala:38)
	at scala.cli.commands.ScalaCommand.run(ScalaCommand.scala:390)
	at scala.cli.commands.ScalaCommand.run(ScalaCommand.scala:371)
	at caseapp.core.app.CaseApp.main(CaseApp.scala:166)
	at scala.cli.commands.ScalaCommand.main(ScalaCommand.scala:356)
	at caseapp.core.app.CommandsEntryPoint.main(CommandsEntryPoint.scala:370)
	at scala.cli.ScalaCliCommands.main(ScalaCliCommands.scala:125)
	at scala.cli.ScalaCli$.main0(ScalaCli.scala:320)
	at scala.cli.ScalaCli$.main(ScalaCli.scala:124)
	at scala.cli.ScalaCli.main(ScalaCli.scala)

Btw, I also don't understand the warning

Warning: Only java properties are supported in JAVA_OPTS and JDK_JAVA_OPTIONS environment variables. Other options are ignored: -Xmx4000m, -Xms256m

Are -Xmx and -Xms not java properties?

@tgodzik
Copy link
Contributor

tgodzik commented Jan 15, 2025

Are -Xmx and -Xms not java properties?
Since this is a native image only properties with -D will work, con JVM options will.

Did you by any chance clean your caches at any point? This usually happens if we generate bloop config which has hardcoded paths and later those are removed. Bloop doesn't download anything by itself.

You could probably remove .scala-build and rerun scala-cli which should download the jars again. Or you could add --server=false

Maybe we could redownload in those cases?

@tgodzik tgodzik added this to the Bloop 2.0.8 milestone Jan 15, 2025
@odersky
Copy link
Author

odersky commented Jan 15, 2025

Ah, it works again when I remove .scala-build.

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

2 participants