lucidsoftware / neo-sbt-scalafmt

Scalafmt SBT plugin
Apache License 2.0
149 stars 25 forks source link

neo-sbt-scalafmt + Scala 2.11 + `fork in Test := true` = NoSuchMethodError #64

Open SethTisue opened 6 years ago

SethTisue commented 6 years ago

I had to remove neo-sbt-scalafmt (1.4) from my project because:

    [error] Uncaught exception when running tests:
    [error] java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps;
    [error] sbt.ForkMain$ForkError: java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps;
    [error]         at org.scalatest.tools.FriendlyParamsTranslator$.translateArguments(FriendlyParamsTranslator.scala:174)
    [error]         at org.scalatest.tools.Framework.runner(Framework.scala:929)
    [error]         at sbt.ForkMain$Run.runTests(ForkMain.java:252)
    [error]         at sbt.ForkMain$Run.run(ForkMain.java:139)
    [error]         at sbt.ForkMain$Run.access$100(ForkMain.java:135)
    [error]         at sbt.ForkMain.main(ForkMain.java:121)

this was happening consistently when trying to run my ScalaTest tests on 2.11 with fork in Test := true

the refArrayOps thing usually indicates a Scala 2.11/2.12 mismatch

the cause seems to be:

sbt:scala-fortify> show test:fullClasspath
[info] Updating {file:/Users/tisue/scala-fortify-plugin/}scala-fortify-plugin...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/tisue/scala-fortify-plugin/target/scala-2.11/classes ...
[info] Done compiling.
...
[info] * Attributed(/Users/tisue/.sbt/boot/scala-2.12.4/lib/scala-library.jar)
...

how'd the 2.12.4 stdlib get in there? that's not right.

what it is about this plugin that actually causes that, I don't know.

the problem occurs with both sbt 1.0.4 and 0.13.16

SethTisue commented 6 years ago

note that the incorrect entry in test:fullClasspath is there even without fork in Test := true.

it's just that the incorrect entry hasn't personally caused me any trouble unless I also enable fork in Test := true

pauldraper commented 6 years ago

There is some weirdness around this.

I suggest trying sbt-scalafmt-coursier instead of sbt-scalafmt.