[2.x] fix: Allow dependencyTree to run despite eviction errors (#8554)

**Problem**
When binary compatibility eviction errors occur, users cannot run
`dependencyTree` to debug the dependency conflict because it fails
with the same eviction error.

**Solution**
Set `evictionErrorLevel` and `assumedEvictionErrorLevel` to `Level.Warn`
for the `dependencyTreeIgnoreMissingUpdate` task, allowing the dependency
tree to be displayed even when eviction errors are present.

Fixes #7255
This commit is contained in:
Pegasus 2026-01-15 22:52:38 -05:00 committed by GitHub
parent 710d4a911b
commit 79c60ca4c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 2 deletions

View File

@ -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

View File

@ -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)
)

View File

@ -0,0 +1,2 @@
# Test that dependencyTree works despite eviction errors (issue #7255)
> dependencyTree