6

I have tried installing SBT for Scala, but get this weird exception when starting it:

Exception in thread "main" java.lang.IncompatibleClassChangeError: Expected static method scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps;
at xsbt.boot.Boot$.main(Boot.scala:11)
at xsbt.boot.Boot.main(Boot.scala)

My Java version is

java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

I installed SBT via (home)brew and got version 0.13.9.

I have tried to update Java to the latest version, but it doesn't help. Of course I have uninstalled and reinstalled SBT, both with and without homebrew, but I get the same error. I can't figure out why this error occurs.

Jonas Lomholdt
  • 1,215
  • 14
  • 23
  • 1
    `IncompatibleClassChangeError` indicates a binary incompatibility problem. What version of Scala are you running? How are you starting sbt? Are you starting sbt on a particular project? – moem Nov 19 '15 at 15:32
  • You could try the sbt 'rebel cut' script by PaulP: https://github.com/paulp/sbt-extras - just save that file somewhere and run it directly as a shell script instead of the original sbt. – 0__ Nov 19 '15 at 15:43
  • @moem I'm on `Scala version 2.11.7`. I run SBT by running `$ sbt` on the command line. The error is the same when starting SBT on a particular project and while not doing that. @0__ Thanks for the suggestion, I tried but it yields the same error as mentioned. – Jonas Lomholdt Nov 19 '15 at 16:10
  • Are you doing anything to change the scala version of sbt? Only 2.10 can be used to run sbt. Particularly, in no circumstances are you to set `scalaVersion` in any `project/*.sbt` file – pfn Nov 20 '15 at 05:07
  • @pfn My *.sbt file does indeed set the `scalaVersion := "2.11.7"` but removing it does not help. Also, I have tested this setup on another machine without problems. – Jonas Lomholdt Nov 20 '15 at 08:55
  • Your project's build.sbt can specify any scalaVersion it wants. The build's build.sbt cannot. That includes any files in ~/.sbt/0.13/plugins – pfn Nov 20 '15 at 14:45
  • Unfortunately nothing of this seems to work. I tried to run it through IntelliJ with no luck. It spits out the same error. – Jonas Lomholdt Nov 20 '15 at 16:25
  • I never found a way to fix this issue, so I ended up formatting my computer which (obviously) did the trick. If anyone finds a proper solution, please don't hold it back :) – Jonas Lomholdt Jan 05 '16 at 18:05
  • https://stackoverflow.com/questions/75947449/run-a-scala-code-jar-appear-nosuchmethoderrorscala-predef-refarrayops – Dmytro Mitin Apr 07 '23 at 04:58

1 Answers1

0

Remove any extraneous JAR files from your Java Extensions directory. I came across the same error after building BFG Repo-Cleaner and then installing the resulting bfg.jar into /Library/Java/Extensions under macOS. After that, sbt failed with the above error message until bfg.jar was removed from /Library/Java/Extensions.