[英]How to setup different Scala versions on the same machine?
I want to follow the book on Scala[1] but it uses Scala 3 and I have Scala 2 installed.我想关注关于 Scala[1] 的书,但它使用 Scala 3 并且我安装了 Scala 2。 I want to use both the versions, something on the lines of
python2
and python3
.我想使用这两个版本,在
python2
和python3
行。
I tried installing Scala3 on my local using the official source but I could only grasp the project-level working directory.我尝试使用官方源在本地安装 Scala3,但我只能掌握项目级工作目录。 The
sbt
prompt does not work like a REPL would and I can only open REPL using Scala 2 (I checked the version everytime). sbt
提示符不像 REPL 那样工作,我只能使用 Scala 2 打开 REPL(我每次都检查版本)。
How do I open the REPL of Scala3 given I cannot uninstall Scala2?鉴于无法卸载 Scala2,如何打开 Scala3 的 REPL?
The sbt prompt does not work like a REPL
sbt 提示不像 REPL 那样工作
If you execute sbt console
from within project directory it will drop you into REPL version corresponding to the project's scalaVersion
.如果您从项目目录中执行
sbt console
,它将使您进入与项目的scalaVersion
对应的 REPL 版本。 For example, executing sbt console
within project created with sbt new lampepfl/dotty.g8
would start Scala 3 REPL.例如,在使用
sbt new lampepfl/dotty.g8
创建的项目中执行sbt console
将启动 Scala 3 REPL。
but I could only grasp the project-level working directory
但我只能掌握项目级工作目录
For system-wide installation first install coursier and then execute cs install scala3-repl
.对于系统范围的安装,首先安装 coursier ,然后执行
cs install scala3-repl
。 This will install Scala 3 REPL alongside the Scala 2 one.这将在 Scala 2 旁边安装 Scala 3 REPL。 Now Scala 3 REPL can be started with
scala3-repl
command whilst Scala 2 REPL simply with scala
command.现在 Scala 3 REPL 可以使用
scala3-repl
命令启动,而 Scala 2 REPL 只需使用scala
命令即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.