26

I currently had installed scala 2.11.7 but 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

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

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

1
  • Is there a download page with direct links for HTTP download? I need the scala-library.jar with a checksum of 458d046151ad179c85429ed7420ffb1eaf6ddf85. Commented May 29, 2019 at 0:47

5 Answers 5

38

The following should work for Homebrew 0.9.5:

Install Tapped version of Scala 2.10

brew install homebrew/versions/scala210

Unlink version of Scala 2.11 (if installed)

brew unlink scala

Link Tapped version of Scala 2.10

brew link scala210 --force

Check scala version

scala -version
4
  • I am not able to use the brew switch command to switch between the versions after this. I always have to do a link and unlink. Do you know how to fix this?
    – Saket
    Commented Feb 8, 2016 at 12:00
  • I created the following aliases to help me for the time being. # Setup the following aliases alias use_scala210='brew unlink scala && brew unlink scala210 && brew link scala210 --force' alias use_scala211='brew unlink scala && brew unlink scala210 && brew link scala'
    – Saket
    Commented Feb 8, 2016 at 12:12
  • This is the best answer. Commented Dec 5, 2016 at 22:32
  • 2
    This answer may need to be updated, I attempted to brew install homebrew/versions/scala210 and i got this response Error: homebrew/versions was deprecated. This tap is now empty as all its formulae were migrated. Commented Jun 4, 2020 at 15:46
30
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

brew install [email protected]
19

If you manage your project with sbt, the scala built tool, either directly or via IntelliJ, the version of scala for that code is defined in the build file (build.sbt or Build.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 ivy repository, so it doesn't have to download it each time.

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

2
  • I tried sbt but was having issues syncing with intellij. Do you have any links to guide me though the usage of sbt?
    – Rahul
    Commented Sep 24, 2015 at 19:14
  • With IDEA 14.x it's gotten pretty full proof. I wrote it up here: gist.github.com/sdether/ea9196b10cdb46757d5f Main caveat is the waiting after you create the project as now it will resolve the scala version, download it and its dependencies, all of which takes a while. Commented Sep 24, 2015 at 19:27
5

Homebrew installs scala 2.10.5 with the formula scala210:

$ 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 IntelliJ and IntelliJ should automatically use the dependencies defined in your build config.

3
  • @Rahul have you tried upgrading brew? I'm running version 0.9.5 Commented Sep 24, 2015 at 18:37
  • Yes, I have upgraded brew. This is my current version - Homebrew 0.9.5 (git revision 596b9; last commit 2015-09-24)
    – Rahul
    Commented Sep 24, 2015 at 19:06
  • I am not able to use the brew switch command to switch between the versions after this. I always have to do a link and unlink. Do you know how to fix this?
    – Saket
    Commented Feb 8, 2016 at 12:00
1

Using brew to install specific version:

$ 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

Not the answer you're looking for? Browse other questions tagged or ask your own question.