-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
fix: cleanup removing shared resources needed by multiple formulas #21358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implementation DetailsChanges made to
How to verify the fix: # Fetch both formulas that share the same patch
brew fetch --build-from-source python@3.14 python@3.13
# Check downloads directory - patch file exists
ls "$(brew --cache)/downloads"
# Cleanup first formula
brew cleanup python@3.14
# Verify patch file still exists (because python@3.13 still references it)
ls "$(brew --cache)/downloads"The fix ensures that when Note: This PR contains only additions to the codebase - no deletions or modifications to existing code/comments. Would appreciate a review from the maintainers. Thanks! |
|
All CI checks are now passing! The fix has been tested and is ready for review. Please let me know if any changes are needed. |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great so far, thanks! Where is the original symlink logic? It might be nice to consolidate this logic with that logic so that there's no drift in this logic over time.
|
@MikeMcQuaid I've applied your suggestions but running into a type checking error. Here's what I did: Changes applied:
Current code (line 32): @symlink_targets = T.let({}, T::Hash[Pathname, Set[Downloadable]])Type error: The issue: I believe the confusion is:
Updated line 32: @symlink_targets = T.let({}, T::Hash[Pathname, T::Set[Downloadable]])Is this the correct approach - using All other checks pass, just this one type annotation issue. Let me know if I should approach this differently! All CI checks are now passing! |
Yes 👍🏻 |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the original symlink logic? It might be nice to consolidate this logic with that logic so that there's no drift in this logic over time.
@ooye-sanket thoughts on this?
|
@MikeMcQuaid Good point! I'll consolidate the symlink logic. I'll extract it into a helper method in Pushing the update now. |
When multiple formulas (e.g., python@3.14 and python@3.13) share the same resource file, the download queue deduplicates downloads but only creates a single symlink for the first formula. This causes brew cleanup to remove the shared resource when cleaning the first formula, breaking subsequent formula upgrades. The fix tracks all formulas requesting each resource and creates a separate symlink for each after the download completes. This ensures reference counting works correctly during cleanup - the file in downloads/ will only be removed when ALL symlinks pointing to it are gone.
|
@MikeMcQuaid Thank you for rebasing the branch! All checks are passing now. |
|
Thanks @ooye-sanket, great work here! |
When multiple formulas (e.g., python@3.14 and python@3.13) share the same resource file, the download queue deduplicates downloads but only creates a single symlink for the first formula. This causes brew cleanup to remove the shared resource when cleaning the first formula, breaking subsequent formula upgrades.
The fix tracks all formulas requesting each resource and creates a separate symlink for each after the download completes. This ensures reference counting works correctly during cleanup - the file in downloads/ will only be removed when ALL symlinks pointing to it are gone.
Fixes #21327
brew lgtm(style, typechecking and tests) with your changes locally?