35

I tried to install Scala 2.12.1 on my Mac (El Capitan) via Homebrew and also by downloading the binaries from https://www.scala-lang.org/download/.

In both cases, whenever I run scala (or scalac, scaladoc, etc) I get this printed to screen:

cat: /release: No such file or directory

The action is successful however. E.g. scala myscript.scala works just fine, but that error message gets printed first.

Does anyone have an idea of why that's happening?

S.I.
  • 3,250
  • 12
  • 48
  • 77
trianta2
  • 3,952
  • 5
  • 36
  • 52

3 Answers3

34

Opening up bin/scala, there's a line:

java_release="$(cat $JAVA_HOME/release | grep JAVA_VERSION)"

My $JAVA_HOME wasn't set. All fixed now.

S.I.
  • 3,250
  • 12
  • 48
  • 77
trianta2
  • 3,952
  • 5
  • 36
  • 52
  • 12
    It's https://issues.scala-lang.org/browse/SI-10098. Regression in Scala 2.12.1, fix is already in for 2.12.2 (coming in February or thenabouts). – Seth Tisue Dec 18 '16 at 01:53
  • I faced this issue after starting to use [jenv](http://www.jenv.be/) to manage Java versions. The simplest solution in this case was to enable the export plugin for jenv via `jenv enable-plugin export` to export `$JAVA_HOME` automatically. – Mandar Pathak Apr 03 '17 at 21:17
20

I would add this as a comment but can't as of yet due to my newbie status. To specifically fix your $JAVA_HOME - if you're on UNIX you can copy and paste this in to your Terminal:

export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"

Replace the 1.8 with whatever version of Java you are currently working from.

NateH06
  • 3,154
  • 7
  • 32
  • 56
1

Try setting your JAVA_HOME environment variable. In my case, JAVA_HOME was already set.

I got the error specifically

cat: /usr/lib/jvm/java-8-openjdk-amd64/release: No such file or directory

I got it fixed by creating an empty file release in it

sudo touch $JAVA_HOME/release

My JAVA_HOME looks like

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64`

That's a hack, but it just works fine for me!

There doesn't seem to be any hard doing that also if you look at what does happen with this /release file while running scala; https://github.com/scala/scala/pull/5588/files.

Caution: This solution is only applicable when you don't have release file in place.

Fahad Siddiqui
  • 1,829
  • 1
  • 19
  • 41