12
  • First I installed macports

  • Then I installed Scala and Play through macports: To make sure installation works I run a "hello world" on eclipse. It works!

  • But since my objective is to use Intellij, I try to follow the instructions at http://confluence.jetbrains.com/display/SCA/Getting+Started+with+IntelliJ+IDEA+Scala+Plugin

  • On step 3 of the instructions (section Creating a Project), under use scala distribution, I am not sure what to type. Will someone please tell me what to type? I am using mac os x mountain lion. I don't know the path to my scala installation.

I appreciate the help. I have already looked at Intellij Idea setup for Scala, clarification needed. No help there. My Intellij version is 12.0.3 and my scala install is 2.10.

0

5 Answers 5

22

Just for clarification: you can install scala in Mac OS X using Homebrew as @JasonG mentions:

$ brew install scala --with-docs

In that case, the selected solution won't work, as IntelliJ will still complain. Any way, as stated in the caveats of the formula, you will have a directory specially crafted for IntelliJ integration:

==> Caveats To use with IntelliJ, set the Scala home to: /usr/local/opt/scala/idea

Using this directory will make IntelliJ happy.

UPDATE for IntelliJ IDEA 13.x users: This doesn't seem to be needed any more. Just use SBT based projects, and everything will be downloaded and configured automatically (Scala compiler and libraries)

2
  • 2
    Is there a place in IntelliJ 13.1.2 to set this? I can't find it. May 2, 2014 at 21:16
  • I have just started playing with IntelliJ 13 and Scala, but it seems that this is not needed any more: you can now use SBT and specify which scala version you want to use. SBT automatically downloads the compiler and libraries, and they will "magically" appear in the project structure and configuration. May 19, 2014 at 8:59
7

You're much better served by letting existing tools do this sort of thing for you.

Define your project using SBT. Use PaulP's (Paul Phillips) SBT launcher and the sbt-idea plug-in that provides automatic generation of IDEA project and module files.

See my previous answer for some details

2
  • How is SBT going to edit your code, or do syntax highlightling, or navigate the source code? May 19, 2013 at 20:22
  • I guess you misunderstand my recommendation. I strongly advise defining your project in SBT, using the sbt-idea plug-in for SBT and use it to generate your IDEA project definitions. May 19, 2013 at 23:22
4

I don't know OSX but presumably you can open a terminal, type ls -l `which scala` into it, and get the path to the scala executable.

You can then enter that path, without the /bin/scala on the end, into the intellij dialogue.

2
  • I tried that and got /opt/local/bin/scala. But when I enter that the error is not valid Scala home
    – learner
    Feb 11, 2013 at 17:47
  • That's probably because it's a symlink to the real scala install. Try doing "ls -l `which scala`" and you should see where it's pointing to. If that works I will update the answer. Feb 11, 2013 at 17:50
1
  1. find and install scala plugin in "Preference" -> "Plugins" -> "Browse repositories" -> "Scala"
  2. open project and
  3. open"Project Structure"
  4. open "Facets"
  5. press "Add" / "Plus icon"
  6. select "Scala"

Then you can select scala version and setup compiler

1
  • By Project Structure do you mean the tab that says 7:structures? If so it has two folders in it: Libraries and Module Dependencies. Where do I find Facets?
    – learner
    Feb 11, 2013 at 17:43
1

I actually downloaded the scala and scala docs from typesafe, unzipped them in a folder as per the instructions, and then pointed intellij at that. Use the sbt plugin as well - it makes life much better.

Alternatively you can use brew to install scala with docs:

$ brew install scala --with-docs

2.9.2 instructions here should work. http://scalacookbook.blogspot.ca/2012/09/scala-for-intellij.html

As a third option, you can just let intellij download scala for you. If it's not found, there is a download button you can hit. I'm not sure if it gets the docs though.

2
  • 2
    I love HomeBrew, but when you care about having a specific version or more than one version available, it falls short. When it comes to Scala, I usually do need multiple versions. The SBT + PaulP launcher + sbt-idea is the best way to achieve that with the least effort and least likelihood of configuration mistakes. Feb 11, 2013 at 17:55
  • You can install multiple versions and switch on cli ie see here: gist.github.com/fabiofumarola/4118557
    – JasonG
    Feb 11, 2013 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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