Description
Is your feature request related to a problem? Please describe.
On systems for which there is no Java 17+ listing in Coursier's jvm-index, if the JVM isn't provided on Scala CLI startup (i.e. via an environment variable), the error we are printing seemingly coming straight from Coursier) is quite cryptic, and it's not indicating what the user should do in any way. OpenBSD is an example of such an OS.
scala $ env JAVA_HOME=/usr/local/jdk-1.8.0 scala
Error: java.lang.Exception: Unrecognized OS: openbsd
For more details, please see '/usr/ports/lang/scala/.scala-build/stacktraces/1725217762-8871160887746307735.log'
scala $ cat /usr/ports/lang/scala/.scala-build/stacktraces/1725217762-8871160887746307735.log
java.lang.Exception: Unrecognized OS: openbsd
coursier.jvm.JvmIndex$.defaultOs(JvmIndex.scala:173)
scala.build.internal.OsLibc$.jvmIndexOs$lzyINIT1(OsLibc.scala:59)
scala.build.internal.OsLibc$.jvmIndexOs(OsLibc.scala:58)
scala.cli.javaLauncher.JavaLauncherCli$.runAndExit(JavaLauncherCli.scala:22)
scala.cli.ScalaCli$.main0(ScalaCli.scala:251)
scala.cli.ScalaCli$.main(ScalaCli.scala:117)
scala.cli.ScalaCli.main(ScalaCli.scala)
Describe the solution you'd like
We need a better error message, optimally explaining to the user what he could do to make Scala CLI work.
The workaround of using --server=false
should also be suggested.
Describe alternatives you've considered
We could try to improve the jvm-index
system coverage, but that's tricky and there's always some niche OS that we won't be able to cover and its (power) users would still have to set up the JVM themselves.
Additional context
Extracted out of: