Scala SBT / Maven2 Error on OSX: "Error Opening Zip File" -> MissingRequirementError
Asked Answered
K

3

5

I have a project that builds well on Unix boxes (http://www.github.com/jhclark/ducttape).

However, using SBT 0.11.2 (and a few other versions of SBT), it will not build on my Mac (OSX 10.5). I get the following cryptic error message:

$ ~/bin/sbt compile                                       (master*? 20:11)
[info] Loading project definition from /Users/jon/Documents/workspace-    scala/ducttape/project
[info] Set current project to ducttape (in build file:/Users/jon/Documents/workspace-scala/ducttape/)
[info] Compiling 104 Scala sources to /Users/jon/Documents/workspace-scala/ducttape/target/scala-2.9.2/classes...
[error] error while loading <root>, error in opening zip file
[error] {file:/Users/jon/Documents/workspace-scala/ducttape/}default-024416/compile:compile: scala.tools.nsc.MissingRequirementError: object scala not found.
[error] Total time: 2 s, completed May 27, 2012 8:12:09 PM

This happens even after I clean things out thoroughly with:

sbt clean clean-files
rm -rf ~/.ivy2 ~/.m2 ~/.sbt

I suspect that the real error is happening in Maven2, which SBT uses for dependency management (see also Maven : error in opening zip file when running maven).

However, I'm stumped after several days. Any ideas?

Kingbolt answered 28/5, 2012 at 0:20 Comment(1)
sbt uses ivy for dependency management, not maven (but your dependencies can come from a maven repo) ...Yuji
T
8

I had similar problems when attempting to use an older version of the sbt-extras launcher with sbt-0.11.3. In my case, it attempted to download a file that didn't exist, and attempted to unzip the 404 error page. The most recent sbt-extras launcher has been fixed for sbt-0.11.3.

Yours sounds different, but they may be due to the the shutdown of scala-tools.org. If you can, I recommend upgrading to sbt-0.11.3.

If you need to continue to use 0.11.2, you should use the 0.11.3-2 launcher, put sbt.version=0.11.2 in project/build.properties, and disable the scalaTools repo in your build.sbt. Mark Harrah posted info on the SBT mailing list.

If this doesn't help, for some reason you're downloading corrupted .jars from somewhere.

Run the command find ~/.ivy2 ~/.m2 ~/.sbt -name "*.jar" -exec unzip -qqt {} \; to find which jar(s) are corrupted. The contents of the corrupt jar may give you a clue as to what's going wrong.

Transform answered 29/5, 2012 at 14:23 Comment(2)
This solution fixes similar issues on Linux too. Thanks dave!Bless
This test unzip command fix my issue. seems like this kind of issues are caused by truncated jar files.Lulualaba
D
2

For completion, I had the same problem and it was a corrupt zip/jar file.

However, Dave's command line checks for the usual classpath directories, where your jar may be.

The one causing me troubles was in fact in my projects ./lib folder. I struggled with this for hours, hopefully this may help someone else.

PS: Thanks a lot Dave!

Dagnah answered 9/4, 2013 at 16:53 Comment(0)
C
1

I just had the same problem (on OSX, and with Scala 2.10.2), but the problem turned out not to be in any of my dependency manager repos, or with SBT or Scala (as for some people).

I had put a JAR into /Library/Java/Home/lib/ext/ for other reasons, but didn't make it group- and world-readable. Only root (it's owner) could read it. I tweaked the permissions, and voila. Scala and SBT suddenly work again.

cd /Library/Java/Home/lib/ext
sudo chmod g+r bcprov-jdk15on-1.47.jar
sudo chmod g+a bcprov-jdk15on-1.47.jar
Circumambulate answered 30/8, 2013 at 18:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.