Timothy Perrigo
Timothy Perrigo

Reputation: 733

Conflicting Akka versions when using Akka / Akka Streams / Akka HTTP

I'm trying to build a project using Scala 2.12.3, sbt 0.13.6, and the following library dependencies in my build.sbt file:

libraryDependencies ++= Seq(
  "com.typesafe.akka" %% "akka-actor" % "2.5.4",
  "com.typesafe.akka" %% "akka-stream" % "2.5.4",
  "com.typesafe.akka" %% "akka-stream-testkit" % "2.5.4" % Test,
  "com.typesafe.akka" %% "akka-http" % "10.0.9",
  "com.typesafe.akka" %% "akka-http-core" % "10.0.9",
  "org.scalatest" %% "scalatest" % "3.0.1" % Test)

However, I keep getting the following warning about version conflicts...It appears that akka-http has a transitive dependency on Akka / Streams version 2.4.19. I found a recent similar post, which advises to explicitly add akka-streams as a dependency and make sure it's the same version as akka-actor. Here are the dependency warnings:

[warn] Found version conflict(s) in library dependencies; some are 
suspected to be binary incompatible:
[warn] 
[warn]  * com.typesafe.akka:akka-stream_2.12:2.5.4 is selected over 
2.4.19
[warn]      +- com.typesafe.akka:akka-http-core_2.12:10.0.9       
(depends on 2.4.19)
[warn]      +- com.werner.opttech:dependency-test_2.12:0.0.0      
(depends on 2.4.19)
[warn] 
[warn]  * com.typesafe.akka:akka-actor_2.12:2.5.4 is selected over 
2.4.19
[warn]      +- com.werner.opttech:dependency-test_2.12:0.0.0      
(depends on 2.5.4)
[warn]      +- com.typesafe.akka:akka-stream_2.12:2.5.4           
(depends on 2.5.4)
[warn]      +- com.typesafe.akka:akka-parsing_2.12:10.0.9         
(depends on 2.4.19)

Any advice on how to resolve this error, so that I can use the latest versions of akka, akka streams, and akka http? Thanks!

Upvotes: 4

Views: 1758

Answers (3)

akauppi
akauppi

Reputation: 18046

Kind of related: akka-http 10.1.0-RC1 removes the transient dependency:

we changed the policy not to depend on akka-stream explicitly any more but mark it as a provided dependency in our build. That means that you will have to always add a manual dependency to akka-stream.

Upvotes: 1

Jeffrey Chung
Jeffrey Chung

Reputation: 19527

Your configuration is correct, as it follows the compatibility guidelines that you mentioned. I think you're misinterpreting the warning messages as errors; you are using the 2.5.4 version of those libraries. Take a closer look at this snippet:

[warn]  * com.typesafe.akka:akka-actor_2.12:2.5.4 is selected over 2.4.19

sbt is indeed picking version 2.5.4 of the akka-actor library instead of version 2.4.19.

Also, running show update in the sbt console outputs the following:

[info]  com.typesafe.akka:akka-actor_2.12
[info]          - 2.5.4
[info]                  status: release
[info]                  publicationDate: Thu Aug 10 09:17:00 EDT 2017
....
[info]          - 2.4.19
[info]                  evicted: true
[info]                  evictedData: latest-revision

sbt evicted version 2.4.19 of akka-actor in favor of version 2.5.4.

The warning messages actually confirm that you're working with the current version of the Akka tools.

Upvotes: 2

jiayp89
jiayp89

Reputation: 533

chunjef's answer is correct.If you want to clear the warning indeed,add the following code to your build.sbt.

conflictManager := ConflictManager.strict

dependencyOverrides += "com.typesafe.akka" %% "akka-actor" % "2.5.4"

dependencyOverrides += "com.typesafe.akka" %% "akka-stream" % "2.5.4"

dependencyOverrides += "org.scala-lang" % "scala-library" % "2.12.3"

Upvotes: 1

Related Questions