scalasbt

Conflicting Cross Version Suffixes Error in Scala Dependencies


In my project, I'm running into conflicting version suffixes error for cats libraries. I ran sbt evicted, but I could not fully make sense of how to interpret it to resolve this error. Here is the evicted output:

    * org.scala-lang:scala-library:2.13.12 is selected over {2.13.10, 2.13.8, 2.13.5}
[warn]      +- org.scala-lang:scala3-library_3:3.4.0              (depends on 2.13.12)
[warn]      +- org.typelevel:cats-kernel_2.13:2.9.0               (depends on 2.13.10)
[warn]      +- org.typelevel:cats-core_2.13:2.9.0                 (depends on 2.13.10)
[warn]      +- org.scala-lang.modules:scala-java8-compat_2.13:1.0.0 (depends on 2.13.5)
[warn]      +- com.typesafe.akka:akka-stream_2.13:2.6.21          (depends on 2.13.8)
[warn]      +- com.typesafe.akka:akka-slf4j_2.13:2.6.21           (depends on 2.13.8)
[warn]      +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.13.8)
[warn]      +- com.typesafe.akka:akka-parsing_2.13:10.2.10        (depends on 2.13.8)
[warn]      +- com.typesafe.akka:akka-http-core_2.13:10.2.10      (depends on 2.13.8)
[warn]      +- com.typesafe.akka:akka-actor_2.13:2.6.21           (depends on 2.13.8)
[warn]      +- com.typesafe.akka:akka-actor-typed_2.13:2.6.21     (depends on 2.13.8)
[warn]      +- com.typesafe:ssl-config-core_2.13:0.6.1            (depends on 2.13.8)
[warn]      +- com.fasterxml.jackson.module:jackson-module-scala_2.13:2.14.3 (depends on 2.13.10)
[warn] To force scalaVersion, add the following:
[warn]  scalaModuleInfo ~= (_.map(_.withOverrideScalaVersion(true)))
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn]  * com.fasterxml.jackson.module:jackson-module-scala_2.13:2.14.3 is selected over 2.11.4
[warn]      +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 2.14.3)
[warn]      +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[warn]  * com.typesafe:ssl-config-core_2.13:0.6.1 is selected over 0.4.3
[warn]      +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 0.6.1)
[warn]      +- com.typesafe.akka:akka-stream_2.13:2.6.21          (depends on 0.4.3)
[info] Here are other dependency conflicts that were resolved:
[info]  * com.typesafe:config:1.4.3 is selected over {1.4.2}
[info]      +- com.typesafe.play:play-configuration_3:2.9.6       (depends on 1.4.3)
[info]      +- com.typesafe.akka:akka-actor_2.13:2.6.21           (depends on 1.4.2)
[info]      +- com.typesafe:ssl-config-core_2.13:0.6.1            (depends on 1.4.2)
[info]  * com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.3 is selected over 2.11.4
[info]      +- org.playframework:play-json_3:3.0.4                (depends on 2.14.3)
[info]      +- com.typesafe.play:play_3:2.9.6                     (depends on 2.14.3)
[info]      +- com.typesafe.play:play-json_3:2.10.6               (depends on 2.14.3)
[info]      +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info]  * org.reactivestreams:reactive-streams:1.0.4 is selected over {1.0.3}
[info]      +- com.typesafe.play:play-streams_3:2.9.6             (depends on 1.0.4)
[info]      +- com.hivemq:hivemq-mqtt-client:1.3.3                (depends on 1.0.4)
[info]      +- io.reactivex.rxjava2:rxjava:2.2.21                 (depends on 1.0.3)
[info]      +- io.monix:monix-execution_3:3.4.0                   (depends on 1.0.3)
[info]      +- com.typesafe.akka:akka-stream_2.13:2.6.21          (depends on 1.0.3)
[info]  * org.postgresql:postgresql:42.6.0 is selected over 42.3.1
[info]      +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 42.6.0)
[info]      +- org.tpolecat:doobie-postgres_3:1.0.0-RC4           (depends on 42.6.0)
[info]      +- org.postgresql:postgresql:42.3.1                   (depends on 42.3.1)
[info]  * com.h2database:h2:1.4.200 is selected over 1.4.199
[info]      +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 1.4.200)
[info]      +- org.tpolecat:doobie-h2_3:1.0.0-RC4                 (depends on 1.4.200)
[info]      +- com.h2database:h2:1.4.199                          (depends on 1.4.199)
[info]  * ch.qos.logback:logback-classic:1.5.12 is selected over 1.2.6
[info]      +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 1.5.12)
[info]      +- com.typesafe.play:play-logback_3:2.9.6             (depends on 1.5.12)
[info]      +- ch.qos.logback:logback-classic:1.2.6               (depends on 1.2.6)
[info]  * org.checkerframework:checker-qual:3.37.0 is selected over {3.31.0}
[info]      +- org.postgresql:postgresql:42.3.1                   (depends on 3.37.0)
[info]      +- org.postgresql:postgresql:42.6.0                   (depends on 3.31.0)
[info]  * co.fs2:fs2-core_3:3.9.1 is selected over {3.7.0}
[info]      +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 3.9.1)
[info]      +- org.tpolecat:doobie-free_3:1.0.0-RC4               (depends on 3.7.0)
[info]      +- co.fs2:fs2-io_3:3.7.0                              (depends on 3.7.0)
[info]  * com.fasterxml.jackson.core:jackson-annotations:2.14.3 is selected over {2.11.4}
[info]      +- org.playframework:play-json_3:3.0.4                (depends on 2.14.3)
[info]      +- com.fasterxml.jackson.module:jackson-module-scala_2.13:2.14.3 (depends on 2.14.3)
[info]      +- com.typesafe.play:play_3:2.9.6                     (depends on 2.14.3)
[info]      +- com.typesafe.play:play-json_3:2.10.6               (depends on 2.14.3)
[info]      +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info]  * com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.14.3 is selected over 2.11.4
[info]      +- com.typesafe.play:play_3:2.9.6                     (depends on 2.14.3)
[info]      +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info]  * com.fasterxml.jackson.core:jackson-core:2.14.3 is selected over {2.11.4}
[info]      +- org.playframework:play-json_3:3.0.4                (depends on 2.14.3)
[info]      +- com.fasterxml.jackson.module:jackson-module-scala_2.13:2.14.3 (depends on 2.14.3)
[info]      +- com.typesafe.play:play_3:2.9.6                     (depends on 2.14.3)
[info]      +- com.typesafe.play:play-json_3:2.10.6               (depends on 2.14.3)
[info]      +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info]  * org.typelevel:cats-core_3:2.12.0 is selected over {2.10.0, 2.9.0}
[info]      +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 2.12.0)
[info]      +- org.typelevel:cats-free_3:2.9.0                    (depends on 2.9.0)
[info]      +- org.typelevel:cats-effect-kernel_3:3.5.7           (depends on 2.9.0)
[info]      +- org.tpolecat:doobie-free_3:1.0.0-RC4               (depends on 2.9.0)
[info]      +- com.comcast:ip4s-core_3:3.3.0                      (depends on 2.9.0)
[info]      +- co.fs2:fs2-core_3:3.9.1                            (depends on 2.10.0)
[info]  * org.typelevel:cats-effect_3:3.5.7 is selected over {3.5.1, 3.4.8, 3.5.0}
[info]      +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 3.5.7)
[info]      +- org.tpolecat:doobie-free_3:1.0.0-RC4               (depends on 3.5.0)
[info]      +- com.comcast:ip4s-core_3:3.3.0                      (depends on 3.4.8)
[info]      +- co.fs2:fs2-core_3:3.9.1                            (depends on 3.5.1)
[info]  * com.fasterxml.jackson.module:jackson-module-parameter-names:2.14.3 is selected over 2.11.4
[info]      +- com.typesafe.play:play_3:2.9.6                     (depends on 2.14.3)
[info]      +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info]  * com.fasterxml.jackson.core:jackson-databind:2.14.3 is selected over {2.11.4}
[info]      +- org.playframework:play-json_3:3.0.4                (depends on 2.14.3)
[info]      +- com.fasterxml.jackson.module:jackson-module-scala_2.13:2.14.3 (depends on 2.14.3)
[info]      +- com.typesafe.play:play_3:2.9.6                     (depends on 2.14.3)
[info]      +- com.typesafe.play:play-json_3:2.10.6               (depends on 2.14.3)
[info]      +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info]  * com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.3 is selected over 2.11.4
[info]      +- org.playframework:play-json_3:3.0.4                (depends on 2.14.3)
[info]      +- com.typesafe.play:play_3:2.9.6                     (depends on 2.14.3)
[info]      +- com.typesafe.play:play-json_3:2.10.6               (depends on 2.14.3)
[info]      +- com.typesafe.akka:akka-serialization-jackson_2.13:2.6.21 (depends on 2.11.4)
[info]  * org.scala-lang:scala3-library_3:3.4.0 is selected over {3.3.0, 3.2.2, 3.3.4, 3.3.3, 3.0.0, 3.2.1, 3.1.3}
[info]      +- com.openelectrons:ocpp-gateway-server_3:1.0-SNAPSHOT (depends on 3.4.0)
[info]      +- com.openelectrons:ocpiv22-api_3:0.0.1-SNAPSHOT     (depends on 3.4.0)
[info]      +- com.openelectrons:ocpp-messages_3:0.0.1-SNAPSHOT   (depends on 3.4.0)
[info]      +- com.openelectrons:ocpiv22-messages_3:0.0.1-SNAPSHOT (depends on 3.4.0)
[info]      +- com.openelectrons:ocpp-j-api_3:0.0.1-SNAPSHOT      (depends on 3.4.0)
[info]      +- org.typelevel:literally_3:1.1.0                    (depends on 3.1.3)
[info]      +- org.typelevel:cats-kernel_3:2.12.0                 (depends on 3.3.3)
[info]      +- org.typelevel:cats-free_3:2.9.0                    (depends on 3.2.1)
[info]      +- org.typelevel:cats-effect_3:3.5.7                  (depends on 3.2.2)
[info]      +- org.typelevel:cats-effect-std_3:3.5.7              (depends on 3.2.2)
[info]      +- org.typelevel:cats-effect-kernel_3:3.5.7           (depends on 3.2.2)
[info]      +- org.typelevel:cats-core_3:2.12.0                   (depends on 3.3.3)
[info]      +- org.tpolecat:typename_3:1.1.0                      (depends on 3.2.2)
[info]      +- org.tpolecat:doobie-postgres_3:1.0.0-RC4           (depends on 3.3.0)
[info]      +- org.tpolecat:doobie-hikari_3:1.0.0-RC4             (depends on 3.3.0)
[info]      +- org.tpolecat:doobie-h2_3:1.0.0-RC4                 (depends on 3.3.0)
[info]      +- org.tpolecat:doobie-free_3:1.0.0-RC4               (depends on 3.3.0)
[info]      +- org.tpolecat:doobie-core_3:1.0.0-RC4               (depends on 3.3.0)
[info]      +- org.scodec:scodec-bits_3:1.1.37                    (depends on 3.2.2)
[info]      +- org.scala-lang.modules:scala-xml_3:2.2.0           (depends on 3.3.0)
[info]      +- org.scala-lang.modules:scala-parser-combinators_3:2.3.0 (depends on 3.2.2)
[info]      +- org.playframework:play-json_3:3.0.4                (depends on 3.3.3)
[info]      +- org.playframework:play-functional_3:3.0.4          (depends on 3.3.3)
[info]      +- io.monix:monix-execution_3:3.4.0                   (depends on 3.0.0)
[info]      +- io.monix:implicitbox_3:0.3.4                       (depends on 3.0.0)
[info]      +- com.typesafe.play:twirl-api_3:1.6.8                (depends on 3.3.3)
[info]      +- com.typesafe.play:play_3:2.9.6                     (depends on 3.3.4)
[info]      +- com.typesafe.play:play-streams_3:2.9.6             (depends on 3.3.4)
[info]      +- com.typesafe.play:play-server_3:2.9.6              (depends on 3.3.4)
[info]      +- com.typesafe.play:play-logback_3:2.9.6             (depends on 3.3.4)
[info]      +- com.typesafe.play:play-json_3:2.10.6               (depends on 3.3.3)
[info]      +- com.typesafe.play:play-json-joda_3:2.10.6          (depends on 3.3.3)
[info]      +- com.typesafe.play:play-functional_3:2.10.6         (depends on 3.3.3)
[info]      +- com.typesafe.play:play-filters-helpers_3:2.9.6     (depends on 3.3.4)
[info]      +- com.typesafe.play:play-configuration_3:2.9.6       (depends on 3.3.4)
[info]      +- com.typesafe.play:play-akka-http-server_3:2.9.6    (depends on 3.3.4)
[info]      +- com.comcast:ip4s-core_3:3.3.0                      (depends on 3.2.2)
[info]      +- co.fs2:fs2-io_3:3.7.0                              (depends on 3.2.2)
[info]      +- co.fs2:fs2-core_3:3.9.1                            (depends on 3.3.0)

This is the error that I face:

[error] java.lang.RuntimeException: Conflicting cross-version suffixes in: org.typelevel:cats-kernel, org.typelevel:cats-core
[error]     at scala.sys.package$.error(package.scala:30)
[error]     at sbt.librarymanagement.ConflictWarning$.processCrossVersioned(ConflictWarning.scala:39)
[error]     at sbt.librarymanagement.ConflictWarning$.apply(ConflictWarning.scala:19)
[error]     at sbt.Classpaths$.$anonfun$ivyBaseSettings$71(Defaults.scala:3403)
[error]     at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]     at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error]     at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error]     at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error]     at sbt.Execute.work(Execute.scala:292)
[error]     at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error]     at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]     at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error]     at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
[error]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[error]     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[error]     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[error]     at java.base/java.lang.Thread.run(Thread.java:1583)
[error] (update) Conflicting cross-version suffixes in: org.typelevel:cats-kernel, org.typelevel:cats-core

These are my dependencies:

libraryDependencies ++= Seq(
      // Add explicit Cats dependencies
      "org.typelevel" %% "cats-core" % catsVersion,
      "org.typelevel" %% "cats-kernel" % catsVersion,
      "org.typelevel" %% "cats-effect" % "3.5.7",

      // Database libraries
      "org.postgresql" %  "postgresql" % "42.3.1",
      "com.h2database" % "h2" % "1.4.199",

      "org.tpolecat" %% "doobie-core"     % doobieVersion exclude ("org.typelevel", "cats-core"),
      "org.tpolecat" %% "doobie-postgres" % doobieVersion,
      "org.tpolecat" %% "doobie-h2"       % doobieVersion,
      "org.tpolecat" %% "doobie-hikari"   % doobieVersion,

      "ch.qos.logback" % "logback-classic" % "1.2.6",

      "org.playframework" %% "play-json" % "3.0.4",
      "com.typesafe.play" %% "play-json-joda" % "2.10.6",

      // For caching and distributed caching
      //"com.github.cb372" %% "scalacache-core" % "0.28.0",
      //"com.github.cb372" %% "scalacache-guava" % "0.28.0",

      // For application Metrics
      "io.dropwizard.metrics" % "metrics-core" % dropWizardMetricsVersion,
      "io.dropwizard.metrics" % "metrics-jvm" % dropWizardMetricsVersion,

      // Threading & Streaming libraries (https://monix.io/docs/current/intro/usage.html)
      "io.monix" %% "monix-execution" % "3.4.0",
      "co.fs2" %% "fs2-core" % "3.9.1",

      // MQTT client
      "com.hivemq" % "hivemq-mqtt-client" % "1.3.3",

      // OCPP & OCPI Core libraries
      "com.openelectrons" %% "ocpp-j-api" % "0.0.1-SNAPSHOT",
      "com.openelectrons" %% "ocpp-messages" % "0.0.1-SNAPSHOT",
      "com.openelectrons" %% "ocpiv22-messages" % "0.0.1-SNAPSHOT",
      "com.openelectrons" %% "ocpiv22-api" % "0.0.1-SNAPSHOT",

      // Test libraries
      "org.scalatestplus.play" %% "scalatestplus-play" % "7.0.1" % Test exclude ("org.slf4j", "slf4j-simple"),
      "org.specs2" %% "specs2-core" % "4.20.0" % Test,
      "org.scalacheck" %% "scalacheck" % "1.18.1" % Test,
      "org.testcontainers" % "hivemq" % "1.19.7" % Test,
      "com.dimafeng" %% "testcontainers-scala-scalatest" % "0.41.3" % Test,
      "com.dimafeng" %% "testcontainers-scala-postgresql" % "0.41.0" % Test
      // https://github.com/DanielaSfregola/random-data-generator
      //"com.danielasfregola" %% "random-data-generator" % "2.9" % Test
    )

Solution

  • EDIT: duplicate of Akka HTTP SBT modules were resolved with conflicting cross-version suffixes in ProjectRrf


    On top of what Mateusz explained, the error message is saying that you have some dependencies (cats-kernel and cats-core) pulled both in their Scala 2 and Scala 3 "variants", i.e. cats-core_2.13 and cats-core_3 are pulled (where the suffix is the Scala version).

    This is forbidden.

    This can happen when pulling multiple dependencies transitively and/or when using the SBT for3Use2.13/for2.13Use3 option (doesn't look like you're using it in this case).

    For instance, maybe you're pulling explicitly Cats Scala 3 but you're pulling dependency X in its Scala 2.13 variant (you can, it's compatible with Scala 3) that itself pulls Cats for Scala 2.13.

    In this case you should look to exclude one of the two Cats, most probably the 2.13 one.