1

I want to update a Scala version. I know it be done for a project using scalaVersion function, but I also want to update a default scala version which is used when I type scala in the terminal.

Now I have 2.10.1 scala version.

How do I do that?

1 Answer 1

2

From http://osgux.tumblr.com/post/44635945407/install-scala-2-10-0-in-ubuntu:

$ wget http://www.scala-lang.org/downloads/distrib/files/scala-2.10.3.tgz
$ tar zxf scala-2.10.3.tgz
$ sudo mv scala-2.10.3 /usr/local/scala
$ sudo ln -s /usr/local/scala/bin/scala /usr/local/bin/scala
$ sudo ln -s /usr/local/scala/bin/scalac /usr/local/bin/scalac
$ sudo ln -s /usr/local/scala/bin/fsc /usr/local/bin/fsc
$ sudo ln -s /usr/local/scala/bin/sbaz /usr/local/bin/sbaz
$ sudo ln -s /usr/local/scala/bin/sbaz-setup /usr/local/bin/sbaz-setup
$ sudo ln -s /usr/local/scala/bin/scaladoc /usr/local/bin/scaladoc
$ sudo ln -s /usr/local/scala/bin/scalap /usr/local/bin/scalap

If you just want to install it for yourself, and not for everyone on the machine, replace /usr/local/scala with ~/tools/scala (or some other subfolder of your home folder) and /usr/local/bin with ~/bin.

Comment reply:

Since you already have Scala installed, you can look where Scala scripts are placed by using the command which scala. There are two possibilities:

  1. if you see /opt/scala/scala2.10-1/bin/scala, this means /opt/scala/scala2.10-1/bin is in your $PATH. Find where it is added, and replace it with /opt/scala/scala-2.10.3/bin. Some likely places are ~/.profile, ~/.bash-profile, ~/.bashrc, see others in https://help.ubuntu.com/community/EnvironmentVariables (note that it lists the files I mentioned as "not recommended", but they are still widely used).

  2. If you see /usr/local/bin/scala (or some other folder other then /opt/scala/scala2.10-1/bin), you should replace these files with links like this:

        $ sudo ln -sf /opt/scala/scala-2.10.3/bin/scala /usr/local/bin/scala
    

    (of course, using the correct folder if it isn't /usr/local/bin). Note that the first argument of ln -s is the file you are linking to, the second argument is the link you create, and -f removes the existing destination files.

7
  • What I like is that the major amount of answers about scala here I get from russian programmers.
    – Incerteza
    Commented Nov 26, 2013 at 7:00
  • @Alex, you should not do it like this. You should not manually move around files inside /usr. These files are under control of package manager, so in fact you should find actual deb package or PPA repository or you should create custom Scala installation in your $HOME and put its bin folder in your $PATH. But really, don't ever mess with your /usr system, it will eventually be a great pain for you. Commented Nov 26, 2013 at 7:30
  • I would also recommend creating deb package from Scala installation if you couldn't find one, but manual construction of deb packages is hard (in comparison with e.g. Archlinux packages), so it is better to create local installation and add it to PATH. Commented Nov 26, 2013 at 7:33
  • @VladimirMatveev Fair enough about /usr/share, but wouldn't /usr/local be all right? Or /opt. hivelogic.com/articles/using_usr_local Commented Nov 26, 2013 at 7:45
  • @AlexeyRomanov, you're creating links in /usr/bin. Imagine that you are trying to install a package which provides the same files in future. Don't know about apt, but package manager in Archlinux will complain about conflicting files. If, OTOH, you extract files to, say, /usr/local/share/scala or /opt/scala, and then add corresponding directories to PATH, it would be much better, you're right in this regard. Commented Nov 26, 2013 at 8:01

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