43

I'm getting this error when I try to compile a Scala project in sbt.

Modules were resolved with conflicting cross-version suffixes in {file:/home/seven3n/caja/Flujo_de_caja/}flujo_de_caja:
[error]    com.typesafe.akka:akka-actor _2.11, _2.10
[error]    org.scalaz:scalaz-effect _2.10, _2.11
[error]    org.scalaz:scalaz-core _2.10, _2.11
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) Conflicting cross-version suffixes in: com.typesafe.akka:akka-actor, org.scalaz:scalaz-effect, org.scalaz:scalaz-core

This is my build.sbt file:

scalaVersion := "2.11.0"

resolvers ++= Seq(
  "Sonatype snapshots repository" at "https://oss.sonatype.org/content/repositories/snapshots/",
  "Spray repository" at "http://repo.spray.io/",
  "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
)

libraryDependencies ++= {
  val akkaVersion = "2.3.2"
  val sprayVersion = "1.3.1-20140423"
  val sprayJsonVersion = "1.2.6"
  val reactiveMongoVersion = "0.11.0-SNAPSHOT"
  val scalaTestVersion = "2.1.5"
  val specs2Version = "2.3.11"
  val foloneVersion = "0.12-SNAPSHOT"
  Seq(
    "com.typesafe.akka" %% "akka-actor"        % akkaVersion,
    "com.typesafe.akka" %% "akka-testkit"      % akkaVersion,
    "io.spray"          %% "spray-can"         % sprayVersion,
    "io.spray"          %% "spray-routing"     % sprayVersion,
    "io.spray"          %% "spray-testkit"     % sprayVersion,
    "io.spray"          %% "spray-json"        % sprayJsonVersion,
    "org.reactivemongo" % "reactivemongo_2.10" % reactiveMongoVersion,
    "org.scalatest"     %% "scalatest"         % scalaTestVersion % "test",
    "org.specs2"        %% "specs2"            % specs2Version % "test",
    "info.folone"       % "poi-scala_2.10"     % foloneVersion
  )
}

Any suggestions?

Jacek Laskowski
  • 64,943
  • 20
  • 207
  • 364
Rodrigo Cifuentes Gómez
  • 1,244
  • 2
  • 13
  • 27

4 Answers4

49

The conflicts appear because:

  1. you've specified your Scala version to be 2.11
  2. you've explicitly specified the Scala version (2.10) for the reactivemongo and poi-scala libraries.

The fix is to use the %% operator for those two libraries as well.

"org.reactivemongo" %% "reactivemongo" % reactiveMongoVersion,
"info.folone"       %% "poi-scala"     % foloneVersion

That's the purpose of the %% operator. To append the declared Scala version (2.11 in your case) to the artifact name.

Ionuț G. Stan
  • 160,359
  • 18
  • 179
  • 193
  • 2
    Nope, those libraries can not be found with the %% operator :( – Rodrigo Cifuentes Gómez May 12 '14 at 20:16
  • 4
    @RodrigoCifuentesGómez it means they haven't been migrated to Scala 2.11 yet. I'd go with 2.10 (`scalaVersion := "2.10.4"`) for the time being. The alternative is to start excluding transitive dependencies from the two 2.10 libraries, which will most likely give you headaches due to other classpath conflicts. Most likely at runtime. – Ionuț G. Stan May 12 '14 at 20:18
  • This answer looks correct and to the point to me. If you agree, Rodrigo, it would help other sufferers if you were to approve this (and of course it would reward the author for taking the time to prepare the answer). – AmigoNico Aug 04 '14 at 02:11
5

I had the same problem and I simply removed the scalaVersion tag from my sbt file and modified the line

libraryDependencies += "org.apache.spark" %% "spark-core" % "1.6.0"

to

libraryDependencies += "org.apache.spark" % "spark-core_2.11" % "1.6.0"

and the problem went away.

raam86
  • 6,283
  • 1
  • 25
  • 45
Mayukh
  • 97
  • 1
  • 2
2

I have tried using %% but it didn't work. I have manually excluded it using

("org.reactivemongo" % "reactivemongo" % reactiveMongoVersion)
    .exclude("com.typesafe.akka", "akka-actor_2.10")
    .exclude("org.scalaz", "scalaz-effect")
    .exclude("org.scalaz", "scalaz-core")
1

To investigate who is caller you can use a plugin but an easier way to look into target/scala-2.*/resolution-cache/reports/. There is Ivy's resolution report for each configuration. Look for *-compile.xml and *-test.xml and search for conflicting library. You can see similar with

<module organisation="com.github.nscala-time" name="nscala-time_2.11">
    ...
    <caller organisation="com.tumblr" name="colossus-metrics_2.11" conf="compile, runtime" rev="1.2.0" rev-constraint-default="1.2.0" rev-constraint-dynamic="1.2.0" callerrev="0.7.2-RC1"/>
    ...
</module>

This should tell you the caller of the module.

Roman Kazanovskyi
  • 2,295
  • 1
  • 19
  • 21