Repository navigation
Look up formula cache file names by name only - #24395
Conversation
- `stale_formula?` passed the part of a `HOMEBREW_CACHE` file name before its version to `Formulary.from_rack`, whose fallback to `Formulary.factory` also tries the path and bottle loaders, so a name like `foo.rb` could load a matching file from the working directory. - `.` and `..` made `Keg.from_rack` try to build kegs outside the Cellar, which raised and aborted cleanup. - Reject anything that isn't a formula name, including after stripping `_bottle_manifest`, and pass `from_cache: true` so `from_rack` and `from_keg` only use the API, tap, name and keg loaders. Signed-off-by: Patrick Linnane <patrick@linnane.io>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Cache-specific formula lookup Library/Homebrew/formulary.rb |
from_rack and from_keg accept from_cache. Cache lookups use the :cleanup source, which excludes bottle, URI and path loaders. Other lookup sources retain their existing loader list. |
Cache name validation and cleanup tests Library/Homebrew/cleanup.rb, Library/Homebrew/test/cleanup_spec.rb |
Cleanup rejects extracted names that are . or .. or do not match HOMEBREW_TAP_FORMULA_NAME_REGEX. Valid names use from_cache: true. Tests cover invalid names, local formula evaluation, bottle-loader attempts and updated lookup arguments. |
Priority:
Merge Risk: 
Minimal · up to 2e099
-
Cache cleanup is restricted to the intended lookup sources, with no identified merge-blocking issue.
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title names the main change: formula cache file names are now looked up by name only. The changeset adds name validation in cleanup.rb and passes from_cache: true to Formulary loaders, which matches the title. No search was needed; the assessment rests on the supplied context.
Full details: Description check
-
Explanation
The description explains the problem and the fix. It covers stale_formula? passing cache name fragments to Formulary.from_rack, the rejection of invalid names including after _bottle_manifest is stripped, and the from_cache: true loader restriction. It also lists the new examples. The description is on-topic and specific to the changeset.
-
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
stale_formula?passed the part of aHOMEBREW_CACHEfile name before its version toFormulary.from_rack, whose fallback toFormulary.factoryalso tries the path and bottle loaders, so a name likefoo.rbcould load a matching file from the working directory, and.or..madeKeg.from_racktry to build kegs outside the Cellar and abort cleanup. Cleanup now rejects anything that isn't a formula name, including after stripping_bottle_manifest, and passesfrom_cache: truesofrom_rackandfrom_kegonly use the API, tap, name and keg loaders; new examples cover these names in normal and dry-run cleanup, including through bottle manifests and installed kegs.brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Codex (GPT-6 Sol with Daybreak) wrote the change and tests, checked that each new example fails without its guard and ran
brew lgtm. Claude Code (Opus 5.5) suggested the change, reviewed it and its callers, asked for the bottle manifest and installed keg examples, simplified the loader selection and tests, checked that the new examples still fail without the change and ranbrew lgtm --online.