Edit: I posted a more elaborated comment below that overlaps with this one.
I’ve tried to use the new scala command to run an old script I have that used to work with Scala 2.13.
I noticed the following compatibility issues:
-
the shebang header is different. It now has to be the following:
#!/usr/bin/env scala -S shebangI wonder if it would be possible to remove the
shebangcommand at all (like in the Scala 2 runner)? Otherwise, there should be a good documentation explaining how to migrate from the Scala 2 runner. I wonder if this issue is related to that as well. -
self-executable scripts without extension are not supported. You have to add either the
.scor.scalaextension. When I looked at that, I noticed that the file extensions have different meanings for Scala CLI (ie,.scfiles are interpreted as a “worksheet” whereas.scalafiles are interpreted as regular Scala program— ie, with a “main” method). It seems that the Scala 2 runner supports both use cases regardless of the file extension: if a standard main method is detected, that method is called, otherwise we fallback to the “worksheet” mode (which is similar to the.scmode of Scala CLI). There is an open issue related to that (but there is no discussion about the differences between.scand.scalascripts). -
the
-saveoption is not supported anymore. My understanding is that Scala CLI now always behaves like the Scala 2 runner with the-saveoption. I would suggest recognizing it but showing a warning like “Unnecessary option:-save. This option is always enabled.”