scala-cli
scala-cli copied to clipboard
Dynamically detect the default Scala version to be run with `ammonite`
Version(s) 0.1.12
Describe what needs to be done and why
We needed #1348 to get rid the following problem after bumping to 3.2.0
▶ scala-cli --ammonite
Downloading Ammonite 2.5.4-19-cd76521f
Downloading Ammonite 2.5.4-19-cd76521f sources
[error] Can't download Ammonite 2.5.4-19-cd76521f for Scala 3.2.0.
Ammonite with this Scala version might not yet be supported.
Try passing a different Scala version with the -S option.
We need an automated mechanism to detect what is the Scala version to be run by default along with the --ammonite repl, so that we don't need similar hotfixes whenever Scala is bumped.
Is your feature request related to a past ticket or discussion? #1348 #1327 https://github.com/com-lihaoyi/Ammonite/pull/1286
Describe alternatives you've considered
Don't get me wrong, the hotfix does its job, but it's less than an ideal solution.
We could also just accept that scala-cli --ammonite will fail if ammonite doesn't support the Scala version scala-cli runs on.
Still I think even if explicitly chosen Scala version are ok to fail (i.e. ammonite will always fail if a nightly Scala version is passed), the default at the very least should fallback to the last supported version for as long as we support running the repl with ammonite at all.
As described in #1450, an alternative solution:
We could have a separate Scala 2.12.x, 2.13.x and 3.x.y versions matching the last ones supported by Ammonite. This would let us update Scala CLI's and Ammonite's Scala separately. Additionally, when the last supported Ammonite Scala version and scala-cli Scala version don't match, a warning should be printed when running it with the default settings (when -S and --ammonite-version options are not passed; if they are, it's ok to just fail starting the repl).