Harden build prefix relocation of poured bottles - #23667
Open
MikeMcQuaid wants to merge 1 commit into
Open
Conversation
- `HOMEBREW_RELOCATE_BUILD_PREFIX` was read straight from `ENV` in two places; it is now a hidden `env_config` boolean so it is typed and testable while staying undocumented until the feature is hardened. - A bottle poured with its build prefix patched in place now records `relocated_build_prefix` and `relocated_files` in its tab, so a relocated keg can be told apart from a pristine one when diagnosing bug reports. `Keg#relocate_build_prefix` returns the patched files to make that possible. - The "building from source" warning for a bottle built for another prefix now states how many characters longer or shorter the local prefix is than the bottle's, which decides whether in-place patching could ever apply, without mentioning the hidden variable. This change is part of [`plans/relocatable-bottles.md`](https://github.com/Homebrew/brew/blob/HEAD/Library/Homebrew/plans/relocatable-bottles.md)
carlocab
approved these changes
Aug 26, 2026
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.
Keg#relocate_build_prefixNUL-pads raw prefix strings in pinned bottles at pour time but had no tests beyond one happy path; the hardening cases in the plan each get a spec, and three found bugs.libfoo.soinside/old/prefix/libfoo.so); trailing NUL padding shifted such references onto garbage. Strings with interior loader references are now padded with extra path separators after the prefix, which path resolution ignores, keeping every reference's offset valid. Other strings keep NUL padding.This change is part of
plans/relocatable-bottles.mdbrew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Fable 5 high with local review and testing.