[2.x] fix: Invalidate update cache across commands when dependencies change#8501
Merged
eed3si9n merged 3 commits intosbt:developfrom Jan 12, 2026
Merged
Conversation
eed3si9n
reviewed
Jan 12, 2026
eed3si9n
reviewed
Jan 12, 2026
Member
eed3si9n
left a comment
There was a problem hiding this comment.
Added some comment on the implementation, but overall this is a cool change!
Contributor
Author
|
@eed3si9n Could you please review changes again? |
OlegYch
reviewed
Jan 13, 2026
| > a/update | ||
|
|
||
| # Step 5: Now run itTests/update - should re-resolve with new dependencies | ||
| > show itTests/ourStamp |
Contributor
There was a problem hiding this comment.
i'd suggest adding an actual test, eg
dothetest := assert((Test / managedClasspath).value.toString.contains("cats-core_2.12-2.9.0")),
lm-core/src/main/contraband-scala/sbt/librarymanagement/UpdateStats.scala
Show resolved
Hide resolved
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix update cache invalidation across sbt command invocations when a dependency's dependencies change.
Problem
When project A's dependencies changed and A was compiled in one command, project B (depending on A) would not invalidate its update cache in a subsequent command. This caused stale classpaths.
The root cause was that
depsUpdatedonly checked!stats.cached, which only detected fresh resolves within the same command. When a dependency was served from cache (even if resolved fresh in a previous command),cachedwas markedtrue, causing incorrect cache reuse.Debug scenario from issue:
sbt:aaa> clean
sbt:aaa> a/compile
sbt:aaa> show itTests/depsUpdated
[info] * false <-- BUG: should be true
Solution
Added
stamp: Stringfield toUpdateStatsthat records when the update was resolved. This stamp persists across commands and enables accurate cross-command comparison:!cachedcheck for backwards compatibility with old cachesStringtype allows future transition from timestamps to content hashesChanges
stamp: Stringfield to UpdateStats schema (default""for compat)stamp = System.currentTimeMillis().toStringwhen creating UpdateStatscachedUpdateto compare stamps instead of justcachedflagi8357-transitive-update-invalidationTest plan
lmCore/testpassesscripted dependency-management/i8357-transitive-update-invalidationFixes #8357
Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=148254234