-
Notifications
You must be signed in to change notification settings - Fork 1k
Coursier backend doesn't substitute org.scala-lang artifacts when using a custom scalaOrganization #8821
Description
Steps
// build.sbt
scalaVersion := "3.8.3-RC1-bin-20260218-bb6fc60-NIGHTLY"
scalaOrganization := "ch.epfl.lara"
libraryDependencies += "com.lihaoyi" %% "fansi" % "0.5.0"Then
> show fullClasspathProblem
When scalaOrganization is set to a custom value (e.g. ch.epfl.lara), transitive dependencies on org.scala-lang Scala artifacts are not excluded or rewritten. This results in both org.scala-lang:scala3-library_3 and ch.epfl.lara:scala3-library_3 ending up on the classpath simultaneously.
The old Ivy backend handled this correctly via OverrideScalaMediator (introduced in #2634), which rewrote transitive org.scala-lang dependencies to use the configured scalaOrganization. When sbt switched to Coursier as the default resolver (sbt 1.3+), this substitution behavior was lost.
Workaround
Users must manually exclude the default org's artifacts:
scalaOrganization := "ch.epfl.lara"
// Without this, both org.scala-lang and ch.epfl.lara Scala libraries
// end up on the classpath from transitive dependencies.
excludeDependencies ++= Seq(
ExclusionRule("org.scala-lang", "scala3-library"),
ExclusionRule("org.scala-lang", "scala3-library_3"),
ExclusionRule("org.scala-lang", "scala3-compiler_3"),
)Expected behavior
Setting scalaOrganization should be sufficient. When it differs from org.scala-lang, sbt should automatically exclude the org.scala-lang versions of the managed Scala artifacts (scalaArtifacts) — or substitute them, as the Ivy backend did.
ScalaModuleInfo already carries both scalaOrganization and scalaArtifacts, so all the information needed to generate these exclusions is available.
Environment
- sbt 1.10.1, Coursier backend
- Scala 3.x fork published under a custom organization
Issue description generated by Claude Opus 4.6