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

crash when .java-source only: Error: java.lang.RuntimeException: Expected Scala artifacts to be fetched #2430

Closed
bjornregnell opened this issue Sep 27, 2023 · 1 comment · Fixed by #2431
Labels
bug Something isn't working

Comments

@bjornregnell
Copy link
Contributor

bjornregnell commented Sep 27, 2023

Version(s)

$ scala-cli version
Scala CLI version: 1.0.4
Scala version (default): 3.3.0
$ javac -version
javac 17.0.8

Describe the bug

Scala CLI crashes when there is only .java-source but if a .scala-file is added then it works fine. If the .scala-file is removed then it crashes again.

java.lang.RuntimeException: Expected Scala artifacts to be fetched

See stack trace below.

To Reproduce

$ mkdir scala-cli-issue && cd scala-cli-issue

$ cat >Test.java
public class Test {
  public void hello() {
    System.out.println("Hello!");
  }
}

$ scala-cli repl .
Compiling project (Java)
Compiled project (Java)
Error: java.lang.RuntimeException: Expected Scala artifacts to be fetched
For more details, please see '/home/bjornr/tmp/scala-cli-issue/.scala-build/stacktraces/1695833159-3995895079627923036.log'

$ cat .scala-build/stacktraces/1695833159-3995895079627923036.log 
java.lang.RuntimeException: Expected Scala artifacts to be fetched
  scala.sys.package$.error(package.scala:27)
  scala.cli.commands.repl.Repl$.$anonfun$16(Repl.scala:288)
  scala.Option.getOrElse(Option.scala:201)
  scala.cli.commands.repl.Repl$.runRepl$$anonfun$1(Repl.scala:289)
  scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
  scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
  scala.build.EitherCps$Helper.apply(EitherCps.scala:19)
  scala.cli.commands.repl.Repl$.runRepl(Repl.scala:453)
  scala.cli.commands.repl.Repl$.doRunRepl$1(Repl.scala:149)
  scala.cli.commands.repl.Repl$.doRunReplFromBuild$1(Repl.scala:170)
  scala.cli.commands.repl.Repl$.runCommand(Repl.scala:251)
  scala.cli.commands.repl.Repl$.runCommand(Repl.scala:104)
  scala.cli.commands.ScalaCommand.run(ScalaCommand.scala:364)
  scala.cli.commands.ScalaCommand.run(ScalaCommand.scala:348)
  caseapp.core.app.CaseApp.main(CaseApp.scala:150)
  scala.cli.commands.ScalaCommand.main(ScalaCommand.scala:333)
  caseapp.core.app.CommandsEntryPoint.main(CommandsEntryPoint.scala:120)
  scala.cli.ScalaCliCommands.main(ScalaCliCommands.scala:125)
  scala.cli.ScalaCli$.main0(ScalaCli.scala:245)
  scala.cli.ScalaCli$.main(ScalaCli.scala:108)
  scala.cli.ScalaCli.main(ScalaCli.scala)
$ cat > test.scala
val x = 42

$ scala-cli repl .
Compiling project (Scala 3.3.0, JVM)
Compiled project (Scala 3.3.0, JVM)
Welcome to Scala 3.3.0 (17.0.8, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                            
scala> x
val res0: Int = 42
                                                                                                                                            
scala> Test()
val res1: Test = Test@3d53e876
                                                                                                                                            
scala> res1.hello
Hello!
                                                                                                                                            
scala> :q

$ rm test.scala 

$ scala-cli repl .
Compiling project (Java)
Compiled project (Java)
Error: java.lang.RuntimeException: Expected Scala artifacts to be fetched
For more details, please see '/home/bjornr/tmp/scala-cli-issue/.scala-build/stacktraces/1695833311-1908336239886349367.log'

Expected behaviour
Scala CLI should just work even if only .java in current dir.

@bjornregnell
Copy link
Contributor Author

Many thanks for fixing this @trilleplay 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant