scala 如何安装旧版本的scala

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32767204/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 07:39:01  来源:igfitidea点击:

How to install an older version of scala

scala

提问by Rahul

I currently had installed scala 2.11.7but in order to fix this issue, I have to install a older version of scala(2.10.5). When I try to install with brew, I keep getting the following error

我目前已经安装,scala 2.11.7但为了解决这个问题,我必须安装旧版本的 scala( 2.10.5)。当我尝试使用 brew 安装时,我不断收到以下错误

Error: No available formula for 2.10.5 

I tried downloading the binaries for scala download page but when I load the SDK and all the libraries in IntelliJ, I just get this error

我尝试下载斯卡拉下载页面的二进制代码,但是当我加载SDK和在所有的图书馆IntelliJ,我刚刚得到这个错误

Error:scalac: No 'scala-library*.jar' in Scala compiler classpath in Scala SDK scala-sdk-2.10.5

So what is the right way to install an older version of scala and setting the same in intellij

那么在intellij中安装旧版本scala并设置相同的正确方法是什么

采纳答案by Arne Claassen

If you manage your project with sbt, the scala built tool, either directly or via IntelliJ, the version of scalafor that code is defined in the build file (build.sbtor Build.scala):

如果您使用sbtscala 构建工具直接或通过IntelliJ管理您的项目,则该代码的scala版本在构建文件(build.sbtBuild.scala)中定义:

scalaVersion  := "2.10.5"

Choosing this path, there isn't even a need to install scala on your Mac at all. Each project will have its own version -- pulled from your local ivyrepository, so it doesn't have to download it each time.

选择这条路径,根本不需要在 Mac 上安装 scala。每个项目都有自己的版本——从您的本地ivy存储库中提取,因此不必每次都下载。

And rather than typing scalato get to the REPL, you type sbt consoleto get to the REPL with the project's scala version and dependencies loaded.

并且不是键入scala以获取 REPL,而是键入sbt console以获取加载了项目的 Scala 版本和依赖项的 REPL。

回答by SilviuC

The following should work for Homebrew 0.9.5:

以下应该适用于 Homebrew 0.9.5:

Install Tapped version of Scala 2.10

安装 Tapped 版本的 Scala 2.10

brew install homebrew/versions/scala210

Unlink version of Scala 2.11 (if installed)

取消链接 Scala 2.11 版本(如果已安装)

brew unlink scala

Link Tapped version of Scala 2.10

Link Tapped Scala 2.10 版本

brew link scala210 --force

Check scala version

检查 Scala 版本

scala -version

回答by Suresh Chaganti

brew search scala

then you will find all the available versions like below

然后你会找到所有可用的版本,如下所示

scala                     [email protected]                [email protected]                scalaenv                  scalariform               scalastyle
homebrew/science/scalapack                                                     Caskroom/cask/scala-ide

Then choose whichever version you want to install. say if you want to install scala 2.11 then you can do that by runnig the command like below

然后选择您要安装的任何版本。说如果你想安装 scala 2.11 那么你可以通过运行下面的命令来做到这一点

brew install [email protected]

回答by Sascha Kolberg

Homebrew installs scala 2.10.5 with the formula scala210:

Homebrew 使用公式 scala210 安装 scala 2.10.5:

$ brew install scala210
==> Installing scala210 from homebrew/homebrew-versions
==> Downloading https://homebrew.bintray.com/bottles/scala210-2.10.5.yosemite.bottle.tar.gz

==> Downloading http://www.scala-lang.org/files/archive/scala-2.10.5.tgz
######################################################################## 100,0%

However, if you are using a build tool like maven or sbt, you should be able to set another scala version in your build config. You should then be able to import your project into IntelliJand IntelliJshould automatically use the dependencies defined in your build config.

但是,如果您使用像 maven 或 sbt 这样的构建工具,您应该能够在构建配置中设置另一个 Scala 版本。然后,您应该能够将您的项目导入IntelliJ,并且IntelliJ应该会自动使用在您的构建配置中定义的依赖项。

回答by pitchblack408

Using brew to install specific version:

使用 brew 安装特定版本:

$ brew search scala
==> Formulae
scala                [email protected]           [email protected]            scalaenv             
scalapack            scalariform          scalastyle

==> Casks
scala-ide

Make sure you default version in profile

确保配置文件中的默认版本

$echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile