1

I'm new to both Scala and IntelliJ. I've installed Scala plugin for IntelliJ

I've installed Scala in my Ubuntu system with

sudo apt-get install scala

When I try to create new scala project, I'm required to do Scala Settings.

New Scala Project

But the problem is I couldn't find the the home directory for my Scala installation.

What is the home directory for Scala in my ubuntu?

Thanks.

TheKojuEffect
  • 20,103
  • 19
  • 89
  • 125

2 Answers2

6

The plugin wants to know where the Scala libraries are installed (as it would want to know where the Java SDK is located for a Java module). Note that for different Scala projects you might use different versions of Scala: 2.9.0 or 2.10.2, etc. The dialog offers to download them or you can go to the Scala site and download them yourself. For example, I downloaded scala-2.10.2.tgz from http://www.scala-lang.org/download/ and expanded it in /home/glenn/Applications/Scala/ to /home/glenn/Applications/Scala/scala-2.10.2/. This latter path is what goes in the "Set Scala Home" field in the dialog.

Note that in my case this is preferable to using the apt-get installation of Scala because the API changes so much that I usually end up with different versions of Scala for different projects that I experiment with.

Follow the version links at http://www.scala-lang.org/download/all.html to the version page with the download for the docs.

Note that for me, IDEA wanted the docs to be in the "doc/scala-devel-docs" directory, whereas the downloaded docs decompressed to "scala-docs-2.10.2". I made a link so that IDEA can find them. My 2.10.2 directory looks like this, now.

scala-2.10.2
├── bin
├── doc
│   ├── scala-devel-docs -> scala-docs-2.10.2
│   ├── scaladoc
│   │   └── lib
│   ├── scala-docs-2.10.2
│   │   └── api
│   └── tools
│       ├── css
│       └── images
├── examples
│   ├── actors
│   ├── monads
│   ├── parsing
│   │   └── lambda
│   ├── tcpoly
│   │   └── monads
│   └── xml
│       └── phonebook
├── lib
├── man
│   └── man1
├── misc
│   └── scala-devel
│       └── plugins
└── src
Glenn
  • 6,455
  • 4
  • 33
  • 42
  • +1 for the explanation. But, any idea about scala home directory when installing with `apt-get install scala` ?? – TheKojuEffect Oct 14 '13 at 05:07
  • I set up Scala manually and when I set Scala Home, I get **no /doc/scala-devel-docs/api**, Any idea, where can I get docs? – TheKojuEffect Oct 14 '13 at 17:10
  • 1
    @TheKojuEffect IDEA and SBT (and sooner or later you will be dealing with SBT) both would like to have the Scala home as I described above. Linux distributions have their own conventions for where they put things: executables, libraries, and docs may end up in places that neither IDEA nor SBT can understand. Moreover, the distros are slow to update Scala: 2.10 was out in Jan 04, but Ubuntu 13.04 had, and still has 2.9.2. – Glenn Oct 14 '13 at 18:53
  • I downloaded `scala-docs-2.10.3.txz` but it doesn't contain `api` directory. – TheKojuEffect Oct 15 '13 at 02:24
  • I moved all the docs into api directory. And seems to be working fine. – TheKojuEffect Oct 15 '13 at 02:37
5

Run

$ dpkg -L scala

It will show a list of files in that package. Search for scalac:

$ dpkg -L scala | grep scalac

It will be something like /usr/share/scala/bin/scalac. Strip off /bin/scalac part and you will get Scala home: /usr/share/scala.

Update

It seems that there is no dedicated Scala home in Ubuntu. scala-library package files are installed simply to /usr/share/java. I guess then that the most simple way to get proper Scala home is to download a tarball from http://scala-lang.org/, extract it somewhere and use extracted directory as Scala home.

Vladimir Matveev
  • 120,085
  • 34
  • 287
  • 296
  • 1
    `$ dpkg -L scala | grep scalac` gave two listings. `/usr/bin/scalac` and `/usr/share/man/man1/scalac.1.gz` – TheKojuEffect Oct 14 '13 at 07:44
  • `/usr/share/scala` doesn't exists. :( – TheKojuEffect Oct 14 '13 at 07:44
  • @TheKojuEffect, strange. I guess Scala packaging in Ubuntu differs from Arch more than I expected. Try grepping for `scala-compiler`, it should show something like `/usr/share/scala/lib/scala-compiler.jar`. Then apply the same name transformation. – Vladimir Matveev Oct 14 '13 at 07:54
  • @TheKojuEffect, I think that it is also possible that `scala` package is just an aggregator, and real files are installed with another package. You can try and apply this procedure for all dependencies of `scala` package (except obvious ones, like `java`). My `dpkg`-foo is not advanced enough to suggest exact commands, though :( – Vladimir Matveev Oct 14 '13 at 07:57
  • Grepping for `scala-compiler` gave me nothing. It may be ubuntu specific so I asked http://askubuntu.com/questions/358859/scala-home-directory in AskUbuntu. Thanks for your help. – TheKojuEffect Oct 14 '13 at 09:26
  • 1
    @TheKojuEffect, see an answer here: http://stackoverflow.com/questions/15773293/where-is-scala-home-on-ubuntu. It seems that there is no dedicated Scala home in Ubuntu. I just have inspected official package `scala-library` and indeed, it puts all Scala libraries simply to `/usr/share/java`. I guess the most simple way for you is to download Scala installation tarball, extract it somewhere and use it as Scala home. – Vladimir Matveev Oct 14 '13 at 10:40
  • Thanks, I did the same thing as [Gleen's answer](http://stackoverflow.com/a/19353616/1433665) – TheKojuEffect Oct 17 '13 at 04:01