Getting "cat: /release: No such file or directory" when running scala

12.2k Views Asked by At

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?

3

There are 3 best solutions below

2
On BEST ANSWER

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.

2
On

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.

0
On

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.