diff --git a/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala b/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala index ed47af3af..4661f5fdb 100644 --- a/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala +++ b/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala @@ -24,7 +24,7 @@ import sbt.internal.util.complete.DefaultParsers.* import sbt.io.IO import sbt.io.syntax.* import sbt.librarymanagement.* -import sbt.util.Logger +import sbt.util.{ Level, Logger } import scala.Console private[sbt] object DependencyTreeSettings: @@ -123,9 +123,11 @@ OPTIONS val is = new IvySbt((dependencyTreeIgnoreMissingUpdate / ivyConfiguration).value) new is.Module(moduleSettings.value) }, - // don't fail on missing dependencies + // don't fail on missing dependencies or eviction errors dependencyTreeIgnoreMissingUpdate / updateConfiguration := updateConfiguration.value .withMissingOk(true), + dependencyTreeIgnoreMissingUpdate / evictionErrorLevel := Level.Warn, + dependencyTreeIgnoreMissingUpdate / assumedEvictionErrorLevel := Level.Warn, dependencyTreeIgnoreMissingUpdate := Def.uncached { // inTask will make sure the new definition will pick up `ivyModule/updateConfiguration in ignoreMissingUpdate` Project.inTask(dependencyTreeIgnoreMissingUpdate, Classpaths.updateTask).value diff --git a/sbt-app/src/sbt-test/dependency-graph/eviction-error/build.sbt b/sbt-app/src/sbt-test/dependency-graph/eviction-error/build.sbt new file mode 100644 index 000000000..e5f40f777 --- /dev/null +++ b/sbt-app/src/sbt-test/dependency-graph/eviction-error/build.sbt @@ -0,0 +1,19 @@ +// Test that dependencyTree works despite eviction errors +// This demonstrates the fix for https://github.com/sbt/sbt/issues/7255 + +ThisBuild / scalaVersion := "2.13.12" +ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache" + +// Create a binary incompatible eviction using real Maven dependencies: +// - scalacheck 1.14.3 depends on test-interface 1.0 +// - scalacheck 1.15.4 depends on test-interface 1.0 +// - We force an eviction by depending on incompatible versions +// Or simpler: use libraries with known eviction issues + +// cats-effect 2.x and 3.x are binary incompatible (early-semver) +// fs2 2.5.x depends on cats-effect 2.x +// We also add cats-effect 3.x directly to force eviction +libraryDependencies ++= Seq( + "co.fs2" %% "fs2-core" % "2.5.11", // depends on cats-effect 2.x + "org.typelevel" %% "cats-effect" % "3.3.0" // cats-effect 3.x (incompatible) +) diff --git a/sbt-app/src/sbt-test/dependency-graph/eviction-error/test b/sbt-app/src/sbt-test/dependency-graph/eviction-error/test new file mode 100644 index 000000000..00910adff --- /dev/null +++ b/sbt-app/src/sbt-test/dependency-graph/eviction-error/test @@ -0,0 +1,2 @@ +# Test that dependencyTree works despite eviction errors (issue #7255) +> dependencyTree