Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I overcome "There may be incompatibilities..." SBT warning?

I'm newish to SBT and am not sure what to do about a rather scary warning from the evicted task: [warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.

The full task output is...

sbt:Sprout> evicted
[info] Updating ...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn]  * org.scala-lang.modules:scala-xml_2.12:1.1.0 is selected over 1.0.6
[warn]      +- org.json4s:json4s-xml_2.12:3.6.3                   (depends on 1.1.0)
[warn]      +- org.scalatra:scalatra_2.12:2.6.5                   (depends on 1.0.6)
[warn]      +- com.typesafe.play:twirl-api_2.12:1.3.13            (depends on 1.0.6)
[info] Here are other dependency conflicts that were resolved:
[info]  * org.json4s:json4s-core_2.12:3.6.5 is selected over 3.6.3
[info]      +- org.json4s:json4s-jackson_2.12:3.6.5               (depends on 3.6.5)
[info]      +- org.json4s:json4s-xml_2.12:3.6.3                   (depends on 3.6.3)
[info]      +- org.scalatra:scalatra-json_2.12:2.6.5              (depends on 3.6.3)
[info]  * org.json4s:json4s-scalap_2.12:3.6.5 is selected over 3.6.3
[info]      +- org.json4s:json4s-core_2.12:3.6.5                  (depends on 3.6.5)
[info]      +- org.json4s:json4s-core_2.12:3.6.3                  (depends on 3.6.3)
[info]  * org.json4s:json4s-ast_2.12:3.6.5 is selected over 3.6.3
[info]      +- org.json4s:json4s-core_2.12:3.6.5                  (depends on 3.6.5)
[info]      +- org.json4s:json4s-core_2.12:3.6.3                  (depends on 3.6.3)
[success] Total time: 1 s, completed Apr 13, 2019 12:53:54 PM

"suspected binary incompatible" sound serious. Is it?

Is there just some exclude that I can tag onto the dependencies to get the dependencies in agreement as to what the correct versions are?

The SBT dependencies are like...

libraryDependencies ++= Seq(
  "org.scalatra" %% "scalatra" % ScalatraVersion exclude("org.slf4j","slf4j-api"),
  "org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
  "org.slf4j" % "slf4j-api" % "1.7.26",
  "ch.qos.logback" % "logback-classic" % "1.2.3" % "runtime",
  "org.eclipse.jetty" % "jetty-webapp" % "9.4.9.v20180320" % "container",
  "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
  "org.scalatra" %% "scalatra-json" % ScalatraVersion,
  "org.json4s"   %% "json4s-jackson" % "3.6.5",
)
like image 376
Bob Kuhar Avatar asked Apr 13 '19 20:04

Bob Kuhar


2 Answers

This warning appears because org.scalatra:scalatra_2.12:2.6.5 & com.typesafe.play:twirl-api_2.12:1.3.13 depends on org.scala-lang.modules:scala-xml_2.12:1.0.6, but org.json4s:json4s-xml_2.12:3.6.3 uses org.scala-lang.modules:scala-xml_2.12:1.1.0

In order to hide this warning, you can use dependencyOverrides:

dependencyOverrides += "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6"

Again, it will just hide the warning, but it doesn't guarantee compatibility between your libraries and the version you set.

like image 131
Gal Naor Avatar answered Sep 27 '22 23:09

Gal Naor


Ideally we should resolve evection warnings instead of override, if at all possible, due to potentially introducing hard-to-trace bugs. In this case it is possible if we are willing to drop scalatra and json4s-jackson versions to 2.6.4 and 3.5.2, respectively, like so:

val ScalatraVersion = "2.6.4"

libraryDependencies ++= Seq(
  "org.scalatra" %% "scalatra" % ScalatraVersion exclude("org.slf4j","slf4j-api"),
  "org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
  "org.slf4j" % "slf4j-api" % "1.7.26",
  "ch.qos.logback" % "logback-classic" % "1.2.3" % "runtime",
  "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
  "org.scalatra" %% "scalatra-json" % ScalatraVersion,
  "org.json4s"   %% "json4s-jackson" % "3.5.2",
)
like image 35
Mario Galic Avatar answered Sep 27 '22 21:09

Mario Galic