scalamultiple-versionsscala-repl

Quickly switching Scala versions from CLI


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.


Solution

  • 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.