-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix keg relocation for Homebrew-created files to ensure proper bottling #20657
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
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.
@copilot The approach is sensible but you've added far, far more code than is necessary. Simplify things: DRY, YAGNI, etc. Try to make the bare minimum number of changes in order to achieve the result. The fewer lines in the diff: the better.
Simplified the approach to use DRY and YAGNI principles. Reduced the diff from 198 lines to 44 lines by:
Commit: ac2d888 |
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.
@copilot Still far too much new logic here. Trim it down a lot. Throw away all existing logic and start again.
Threw away the existing logic and implemented a much simpler approach. Reduced from 198 lines to just 21 lines of changes by adding a minimal helper method and modifying the existing replace_text_in_files method inline. Commit: 9be4ca2 |
5eb2402
to
d49b7d9
Compare
- Add homebrew_created_file? method to identify service files - Modify replace_text_in_files to handle Homebrew files separately - Homebrew-created files now get full path relocation instead of selective relocation Co-authored-by: MikeMcQuaid <[email protected]>
d49b7d9
to
088fa1a
Compare
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.
Makes sense!
This PR fixes an issue where Homebrew-created files (such as service definition files) were not being properly relocated when using the new
/usr/local
relocation logic on Intel macOS systems. This was causing bottle creation failures for formulae that generate service files containing generic paths like/usr/local/bin
.Problem
The current keg relocation logic uses selective path replacement when
HOMEBREW_PREFIX=/usr/local
to avoid overzealous replacement of system paths. However, this meant that Homebrew-generated service files containing paths like:Were not getting their
/usr/local
paths replaced with@@HOMEBREW_PREFIX@@
placeholders, making bottles non-relocatable.Solution
The fix introduces minimal logic to identify Homebrew-created files and apply full path relocation to them:
File Detection: Added
homebrew_created_file?()
method that identifies service files (.plist
,.service
,.timer
) with names starting with "homebrew."Inline Relocation Logic: Modified existing
replace_text_in_files()
method to use full prefix replacement for Homebrew-created files when using selective relocation, avoiding code duplicationConditional Processing: Only applies full relocation to Homebrew files when
new_usr_local_relocation?
is true, maintaining selective relocation for regular filesResult
Service files now get properly relocated:
This ensures bottles can be successfully created and relocated between different Homebrew installations without breaking service functionality.
The implementation follows DRY and YAGNI principles with minimal code changes (21 lines added) by reusing existing relocation logic rather than duplicating it.
Fixes #20627.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.