Skip to content

[2.x] fix: Restores Scala 2 reflect/compiler unification#8700

Merged
eed3si9n merged 4 commits intosbt:developfrom
calm329:fix/8689-scala-version-unification
Feb 7, 2026
Merged

[2.x] fix: Restores Scala 2 reflect/compiler unification#8700
eed3si9n merged 4 commits intosbt:developfrom
calm329:fix/8689-scala-version-unification

Conversation

@calm329
Copy link
Copy Markdown
Contributor

@calm329 calm329 commented Feb 6, 2026

Fix Scala 2 artifact version unification

Fixes #8689

What was wrong

Commit 92b0564 (fix for #8632) changed csrSameVersions so that Scala 2.13+ only aligned scala-library and scala3-library. This removed scala-compiler and scala-reflect from version
unification, so transitive dependencies pulling in an older scala-compiler (e.g. 2.13.15 via refined_2.13) were no longer evicted to match scalaVersion (e.g. 2.13.18). The older scala-compiler
brought in jline jars targeting Java 22, breaking builds on older JDKs.

What this PR does

  1. Restore full csrSameVersions for Scala 2.x: All Scala 2 artifacts (scala-library, scala-compiler, scala-reflect, scala-actors, scalap) are aligned again, regardless of minor
    version. Scala 3.x keeps the narrower Scala3_8Artifacts set to avoid aligning artifacts that don't exist across major boundaries.

  2. Exclude scala-library in Scala 2→3.8+ sandwich deps: In projectDependenciesTask, when a Scala 2 project depends on a Scala 3.8+ project, scala-library is excluded from the inter-project
    dependency. This prevents scala-library:3.x from entering the Scala 2 resolution graph and triggering a cross-major-version bump via csrSameVersions. This preserves the fix for [2.x] fix: Fix scala-reflect not found problem #8632.

  3. Restore stdlib-unfreeze test coverage: checkLibs now verifies both scala-library and scala-reflect alignment. The negative assertion (-> b/checkLibs when csrSameVersions := Nil) is
    restored.

Testing

  • mainProj/compile passes.
  • Scripted: dependency-management/stdlib-unfreeze, dependency-management/stdlib-unfreeze-warn, dependency-management/stdlib-unfreeze-update, dependency-management/stdlib-3.8.

@calm329
Copy link
Copy Markdown
Contributor Author

calm329 commented Feb 6, 2026

@eed3si9n Could you please review this pr?

@eed3si9n
Copy link
Copy Markdown
Member

eed3si9n commented Feb 6, 2026

I think +1 on reverting #8632, and then we can follow up with potentially detecting scala-reflect not found whose version >= 3.0 and display a custom error message.

@SethTisue
Copy link
Copy Markdown
Member

fyi @lrytz

@calm329
Copy link
Copy Markdown
Contributor Author

calm329 commented Feb 6, 2026

@eed3si9n Could you re-run the failed CI checks? I don't think they're related to my change

@eed3si9n
Copy link
Copy Markdown
Member

eed3si9n commented Feb 6, 2026

I have but looks like we're hitting the not found issue:

[info] [warn] 	Note: Unresolved dependencies path:
[info] [error] sbt.librarymanagement.ResolveException: Error downloading org.scala-lang:scala-reflect:3.8.1
[info] [error]   Not found
[info] [error]   Not found
[info] [error]   not found: /home/runner/.ivy2/local/org.scala-lang/scala-reflect/3.8.1/ivys/ivy.xml
[info] [error]   not found: https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/3.8.1/scala-reflect-3.8.1.pom

@calm329
Copy link
Copy Markdown
Contributor Author

calm329 commented Feb 6, 2026

Now all checks have passed

Copy link
Copy Markdown
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eed3si9n eed3si9n merged commit 772f616 into sbt:develop Feb 7, 2026
15 checks passed
eed3si9n pushed a commit to eed3si9n/sbt that referenced this pull request Feb 7, 2026
…bt#8700)

Commit 92b0564 (fix for sbt#8632) changed `csrSameVersions` so that Scala 2.13+ only aligned `scala-library` and `scala3-library`. This removed `scala-compiler` and `scala-reflect` from version
unification, so transitive dependencies pulling in an older `scala-compiler` (e.g. 2.13.15 via `refined_2.13`) were no longer evicted to match `scalaVersion` (e.g. 2.13.18).
@ludwiggj
Copy link
Copy Markdown

ludwiggj commented Feb 10, 2026

Hi, apologies for a possibly stupid question, but I can see this is a backport candidate, which should mean that sbt 1.12.1 and 1.12.2 will be patched with this fix, and that the changes will then be automatically picked up in my code, correct?

My question is how will I know when this has happened? Will something be added to the https://github.com/sbt/sbt/releases page? I'm asking as once I know the backport has been published I can remove the temporary workaround I have in place whilst using the current versions of 1.12.1 and 1.12.2. Thanks!

@mzuehlke
Copy link
Copy Markdown
Contributor

A backport would appear in a future 1.12.x release (not 1.11.x)
and be include in the release note of that future release.

You can either rely on system like Dependabot or Scala Steward to create pull request for new releases
or subscribe in Github to new releases of a project: https://github.blog/changelog/2018-11-26-watch-releases/

@eed3si9n
Copy link
Copy Markdown
Member

+1 to what @mzuehlke said. I also usually make announcement on Reddit r/scala, Mastodon, Bluesky, and on Scala Discord sbt channel as well.

@ludwiggj
Copy link
Copy Markdown

ludwiggj commented Feb 11, 2026

Thank you. Just so I'm clear, when that 1.12.x release is made, and announced, I can either move to that new release, or stay on the 1.12.1 release and I will automatically pick up the new backported version of 1.12.1 with this fix in it?

@SethTisue
Copy link
Copy Markdown
Member

SethTisue commented Feb 11, 2026

@ludwiggj version numbers (not just for sbt, but in general in software) are immutable; 1.12.1 and 1.12.2 will remain exactly as they are, from now until the end of time

you need to wait for 1.12.3 to be released

it's possible you're confused about what "1.12.x" means? it's just a shorthand for referring to the entire series 1.12.0, 1.12.1, 1.12.2, 1.12.3, ...

@ludwiggj
Copy link
Copy Markdown

ludwiggj commented Feb 11, 2026

Hi Seth, thanks. I understand what 1.12.x refers to. I think I was just confused but the use of the "backport candidate" label in this fix. What you're saying makes complete sense. So I'll move to 1.12.3 when it becomes available, and I guess 1.12.1 and 1.12.2 will always have this issue.

@SethTisue
Copy link
Copy Markdown
Member

SethTisue commented Feb 11, 2026

👍 (and fyi, in this context, "backport candidate" refers to backporting from sbt 2.x to sbt 1.x)

@eed3si9n eed3si9n changed the title [2.x] fix: Restore Scala 2 artifact version unification (#8689) [2.x] fix: Restores Scala 2 reflect/compiler unification Feb 15, 2026
@eed3si9n
Copy link
Copy Markdown
Member

sbt 1.12.3 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sbt 1.12.1 brings in jline classes targetting java 22

5 participants