Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I best troubleshoot "Potentially incompatible versions of dependencies" in sbt

My project gives the following warning:

[warn] Potentially incompatible versions of dependencies of {file:/some/path/}default-5bae4a:
[warn]    org.scala-lang: 2.9.2, 2.9.1

I've got the following dependencies:

libraryDependencies ++= Seq(
  "io.spray"            %   "spray-can"     % "1.0-M3",
  "io.spray"            %   "spray-routing" % "1.0-M3",
  "io.spray"            %   "spray-testkit" % "1.0-M3",
  "io.spray"            %%  "spray-json"    % "1.2.3" cross CrossVersion.full,
  "com.typesafe.akka"   %   "akka-actor"    % "2.0.3",
  "org.mongodb"         %% "casbah"         % "2.4.1",
  "com.novus"           %% "salat"          % "1.9.1",
  "org.specs2"          %%  "specs2"        % "1.12.2" % "test",
  "org.mockito"         % "mockito-all"     % "1.9.0" % "test"
)

I'm trying to figure our how and to get rid the org.scala-lang 2.9.1 dependency, but it's not as easy as I thought it should be. What trick am I missing?

like image 879
iwein Avatar asked Jan 02 '13 13:01

iwein


People also ask

Which is the correct way to add dependencies in SBT file?

If you have JAR files (unmanaged dependencies) that you want to use in your project, simply copy them to the lib folder in the root directory of your SBT project, and SBT will find them automatically.

How do we specify library dependencies in SBT?

The libraryDependencies key Most of the time, you can simply list your dependencies in the setting libraryDependencies . It's also possible to write a Maven POM file or Ivy configuration file to externally configure your dependencies, and have sbt use those external configuration files.

What is SBT dependency management?

These tools support automatic dependency management for your project. Like in almost every build system, SBT allows you to define library dependencies which are resolved automatically, so you don't have to download and package required libraries by yourself.


1 Answers

First you need to find out which dependency causes this problem by disabling them one by one. Then you can either use a version of that library compiled against 2.9.2 or if there is no such version you can exclude the dependency.

A great tool to figure out which dependency is causing the problem is sbt-dependency-graph.

To exclude a transitive dependency, you can use the exclude method:

libraryDependencies +=
    "com.novus" %% "salat" % "1.9.1" exclude("org.scala-lang", "scalap"),

See here under "Exclude transitive dependencies".

like image 159
Kim Stebel Avatar answered Oct 14 '22 22:10

Kim Stebel