4

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!

Timothy Perrigo
  • 723
  • 4
  • 18
  • It will only resolve the dependencies without any warnings if I remove the dependencies on both akka-actor and akka-streams, but in that case, I would be stuck on akka 2.4.19, correct? – Timothy Perrigo Aug 29 '17 at 13:39

3 Answers3

2

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.

Jeffrey Chung
  • 19,319
  • 8
  • 34
  • 54
  • Yeah, I could see it was evicting 2.4.19 for 2.5.4, but because of the warnings I wasn't sure if I would be causing any new issues. Thanks for the reply! – Timothy Perrigo Aug 30 '17 at 11:49
1

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"
jiayp89
  • 523
  • 2
  • 10
1

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.

akauppi
  • 17,018
  • 15
  • 95
  • 120