4

nvm (Node Version Manager) enables quick selection of alternative Node version to work with. Does Scala have a similar way of quickly switching different versions in the current shell? For example, say I want to start REPL with 2.12.10, then executing something something like

scala use 2.12.10

would greet with

Welcome to Scala 2.12.10 (OpenJDK 64-Bit Server VM, Java 1.8.0_202).
Type in expressions for evaluation. Or try :help.

Note the question is not about SBT via scalaVersion, but using scala command directly from the command line.

Mario Galic
  • 47,285
  • 6
  • 56
  • 98

2 Answers2

6

Alternatively to scala-runners, there's also sdkman, which is a more general tool but also supports scala. For example, command:

sdk use scala 2.12.10

sets scala to 2.12.10 for current shell session.

Krzysztof Atłasik
  • 21,985
  • 6
  • 54
  • 76
3

dwijnand/scala-runners

An alternative implementation of the Scala distribution's runners: scala, scalac, scaladoc, and scalap (no fsc). They are implemented as thin shell scripts around Coursier's coursier launch to add some Scala runners-specific (power) options.

provide a quick way of starting different versions

scala --scala-version 2.12.10

and even development versions from

https://scala-ci.typesafe.com/artifactory/scala-integration
https://scala-ci.typesafe.com/artifactory/scala-pr-validation-snapshots

for example

scala --scala-version 2.13.2-bin-81d1da3

or particular pull request

scala --scala-pr 8960
Mario Galic
  • 47,285
  • 6
  • 56
  • 98