Saturday, June 4, 2016

Scala for OSX

Just a quick note on setting up Scala on OS X. There are several ways to go about getting Scala to work in the Terminal on OS X, but the quickest way I've found is putting Scala on the $PATH and then opening up a new Terminal window.

Once Scala is on the $PATH, it is easy to start Scala's REPL from any Terminal window and just start using Scala for quick tasks directly from the REPL in the Terminal. OS X is a great platform to program Scala from.

To get a set of pre-compiled Scala binaries, go to the Scala's download page. Currently, Scala's download page is at Just click the newest version and get the Scala binaries for your site.

The Scala binaries download as a *.tgz file. On OS X you just need to double-click the *.tgz file to unpack it.

Copy the unpacked Scala folder to the /usr/share folder. It will probably be easiest to do this from the Terminal window, because OS X has crippled its finder so you can't even see the usr directory from /.

The next step is figuring out where OS X has hidden your user profile. On my system, I just type

   cd ~

then look for the file called


It could be in .bash_profile or any number of places. OS X can be a bit flaky that way.

Open your .profile by typing sudo pico .profile, or open it up with vim or emacs or whatever you like editing in. You will need admin access to your OS X box to edit your profile.

Once you have your .profile open, find the line that begins with export PATH=. Above that line, add your SCALA_HOME export. It will look like the following except you may have a version number tacked on to your scala folder name.

   export SCALA_HOME=/usr/share/scala

Now modify the PATH export to include $SCALA_HOME/bin/: between the = and the first path. So the PATH export will start with export PATH=$SCALA_HOME/bin/: followed by whatever paths already existed.

Save your .profile and close all your Terminal windows. You don't have to close the Terminal application, just the windows. Open up a new Terminal window and you should be able to type scala and have a Scala REPL open. Type :quit in the Scala REPL to close it, but keep the Terminal window open.

In the Terminal, you can verify that your $PATH has changed by typing echo $PATH and checking out the results. You can also verify that $SCALA_HOME is set properly by typing echo $SCALA_HOME at the command line and viewing the results.

$SCALA_HOME should look something like /usr/share/scala. And $PATH should look something like


Enjoy your new Scala install and your shiny new Scala REPL. They're very useful and will bring you many hours of enjoyment.

No comments:

Post a Comment