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

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 02:10:43

问题


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?


回答1:


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:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/41193331/getting-cat-release-no-such-file-or-directory-when-running-scala

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!