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.

Community
  • 1
  • 1
learner
  • 11,490
  • 26
  • 97
  • 169

5 Answers5

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)

José González
  • 1,207
  • 12
  • 25
  • 2
    Is there a place in IntelliJ 13.1.2 to set this? I can't find it. – W.P. McNeill May 02 '14 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. – José González May 19 '14 at 08: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

Community
  • 1
  • 1
Randall Schulz
  • 26,420
  • 4
  • 61
  • 81
  • How is SBT going to edit your code, or do syntax highlightling, or navigate the source code? – David Roussel May 19 '13 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. – Randall Schulz May 19 '13 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.

shybovycha
  • 11,556
  • 6
  • 52
  • 82
Brian Smith
  • 3,383
  • 30
  • 41
  • I tried that and got `/opt/local/bin/scala`. But when I enter that the error is `not valid Scala home` – learner Feb 11 '13 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. – Brian Smith Feb 11 '13 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

t3hnar
  • 61
  • 2
  • 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 '13 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.

om-nom-nom
  • 62,329
  • 13
  • 183
  • 228
JasonG
  • 5,794
  • 4
  • 39
  • 67
  • 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. – Randall Schulz Feb 11 '13 at 17:55
  • You can install multiple versions and switch on cli ie see here: https://gist.github.com/fabiofumarola/4118557 – JasonG Feb 11 '13 at 21:24