I have Scala Play 2.6 application on Scala 2.12 (sbt 1.5.5) with "com.eed3si9n" % "sbt-assembly" % "1.2.0". The application uses cats 2.8.0 and I added another library with 0.9.0. This lead the the binary incompatibility issue shown below.
[error] (app / update) found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[error]
[error] * org.typelevel:cats-core_2.12:2.8.0 (early-semver) is selected over {0.9.0, 2.2.0}
[error] +- org.scala-sbt.temp:temp-resolve-4579dec96ae08171122c66ca210e0186a9f70b99:1.0 (depends on 2.8.0)
[error] +- org.typelevel:cats-free_2.12:2.2.0 () (depends on 2.2.0)
[error] +- org.typelevel:cats-laws_2.12:0.9.0 () (depends on 0.9.0)
[error] +- org.typelevel:cats_2.12:0.9.0 () (depends on 0.9.0)
[error] +- org.typelevel:cats-jvm_2.12:0.9.0 () (depends on 0.9.0)
[error] +- org.typelevel:cats-free_2.12:0.9.0 () (depends on 0.9.0)
[error]
[error] * org.typelevel:cats-kernel_2.12:2.8.0 (early-semver) is selected over {2.2.0, 0.9.0}
[error] +- org.typelevel:cats-core_2.12:2.8.0 () (depends on 2.8.0)
[error] +- org.typelevel:cats-laws_2.12:0.9.0 () (depends on 0.9.0)
[error] +- org.typelevel:cats-kernel-laws_2.12:0.9.0 () (depends on 0.9.0)
[error] +- org.typelevel:cats-core_2.12:0.9.0 () (depends on 0.9.0)
[error] +- org.typelevel:cats_2.12:0.9.0 () (depends on 0.9.0)
[error] +- org.typelevel:cats-core_2.12:2.2.0 () (depends on 2.2.0)
I tried this ShadeRule to resolve, but appears not to resolve the issue. (omitted job specific libraries). I tried with .inProject, .inAll, and neither.
ThisBuild / assemblyShadeRules := Seq(
ShadeRule.rename("org.typelevel.**" -> "shadeTypelevel.@1")
.inLibrary(
"org.typelevel" % "cats-core_2.12" % "0.9.0",
"org.typelevel" % "cats-kernel_2.12" % "0.9.0",
"org.typelevel" % "cats-law_2.12" % "0.9.0",
"org.typelevel" % "cats_2.12" % "0.9.0",
"org.typelevel" % "cats-jvm_2.12" % "0.9.0",
"org.typelevel" % "cats-free_2.12" % "0.9.0",
"org.typelevel" % "cats-kernel-laws_2.12" % "0.9.0",
"org.typelevel" % "cats-macros_2.12" % "0.9.0",
).inProject
)
sbt fails immediately with the error provided, so printing a dependency tree has not been possible. Puzzled at what is wrong with my ShadeRule. In version 0.x.x I could chain .inLibrary calls, but with 1.x.x I can only call .inLibrary once? I tried referencing the sbt-assembly GitHub https://github.com/sbt/sbt-assembly#shading.
I usually add
evictionErrorLevel := Level.Warnto bypass this error, but better make sure your application will not fail at runtime by checking withsbt-missinglinkplugin.If you have access to the source code of the super old library you're trying to use, maybe re-building it against a slightly more recent version could eliminate the root cause. (cats 1.x will do, because cats 1.x and 2.x are binary compatible)