Reputation:
I'm running 64-bit OpenSUSE 12.1, today I downloaded the latest Scala 2.9.2 from the official website, after unpacking the tgz and go to scala-2.9.2/bin directory, I executed "scala" and got this error message:
[init] error: error while loading <root>, error in opening zip file
Failed to initialize compiler: object scala not found.
** Note that as of 2.8 scala does not assume use of the java classpath.
** For the old behavior pass -usejavacp to scala, or if using a Settings
** object programatically, settings.usejavacp.value = true.
I attempted to run scala -usejavacp but it doesn't help. I've been using Scala a lot in many other distros and have never got this error before.
My OpenSUSE installation has OpenJDK 6 installed.
Please suggest your opinions, thank you!
I have made the following attempts to solve the problem:
well this is a really interesting problem, I'll definitely post a solution if I can luckily find it.
Thanks a lot for your help!
Last edit: Thanks for everyone here and on reddit (http://www.reddit.com/r/scala/comments/w5s0m/please_help_scala_only_runs_as_root_user_gives/) who offered very valuable suggestions to help me figure out this very strange issue. See my answer below for the solution.
Upvotes: 1
Views: 3186
Reputation: 11
This is most probably caused by jdk-xxx/jre/lib/ext containing jars that is not readable. Please look for file starting with "."jar and "._jar" and remove them.
Upvotes: 0
Reputation:
I have just found out the reason:
A closer examination of the output of "strace -f scala" as normal user yields an interesting output:
[pid 11919] open("/usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/lib/ext/gnome-java-bridge.jar", O_RDONLY) = -1 EACCES (Permission denied)
Soon follow that, is the system call to inform user that scala REPL failed to initialize:
[pid 11919] write(1, "\nFailed to initialize compiler: "..., 260
The gnome-java-bridge.jar has permission 400, I changed it to 444 and problem is solved!
The permission issue seems to have been listed as OpenSUSE bug: http://lists.opensuse.org/opensuse-bugs/2012-07/msg00920.html
Upvotes: 1
Reputation: 297285
It looks like it's not being able to open `scala-library.jar´, or one of the other jar files required for REPL.
You did not say whether scalac works or not. That might give a clue.
At any rate, I'd make sure all of the jar files are a+r, and the directory they are in, as well as all other parent directories, are a+rx.
Upvotes: 0
Reputation: 6609
Do not put sbt-launch.jar in your $SCALA_HOME/lib directory, your project's lib directory, or anywhere it will be put on a classpath.
Upvotes: 1