W.P. McNeill W.P. McNeill -4 years ago 184
Scala Question

Where do I enter the Homebrew Scala path /usr/local/opt/scala/idea in IntelliJ?

When you install Scala using Homebrew you are told

To use with IntelliJ, set the Scala home to:

What exactly does this mean? Is there a global setting in IntelliJ where you enter this path?

Specifically I'm confused because I'm trying to create SBT-backed projects in IntelliJ. In IntelliJ I do New Project -> Scala:SBT and let the IDE create a default project for me. I get a build.sbt that looks like this:

name := "HelloScala"

version := "1.0"

which looks correct. However, the dependencies are on Scala 2.10.2, while the latest Homebrew-installed Scala on my machine (the one that gets used if I type
at the command line) is 2.11.0. I assume the problem is that I don't have
properly set, but I don't see where in the IntelliJ UI to enter this path information. Specifically, none of the IntelliJ Preferences have a text box for "path to Scala distribution" or some such.

How do I properly set up Homebrew Scala with IntelliJ?

IntelliJ 13.1.2, OS X 10.9.2

Answer Source

You need to set scalaVersion in your sbt file or else sbt will use the scala version it was built against.

scalaVersion := "2.11.0"

This will make sbt automagically download the scala 2.11 jars into your ivy cache. Both SBT and IDEA will then use that to compile and run your scala code.

So you wouldn't actually need to install it with homebrew at all unless you want to be able to run the scala repl in a console/manually run scalac etc.

It's only when you do not use the SBT integration you need to point out your scala installation in IDEA.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download