info: avoid broken GitHub URL for removed formulae#22062
Merged
MikeMcQuaid merged 1 commit intoHomebrew:mainfrom Apr 22, 2026
Merged
info: avoid broken GitHub URL for removed formulae#22062MikeMcQuaid merged 1 commit intoHomebrew:mainfrom
MikeMcQuaid merged 1 commit intoHomebrew:mainfrom
Conversation
When a formula has been removed from its tap but is still installed, `FromKegLoader` loads it from the keg's `.brew/<name>.rb` with the tap still set from the install receipt. `github_info` then built a "From:" URL by joining the tap's GitHub remote with `formula.path.relative_path_from(tap.path)`, producing a path full of `../` components, e.g. for `terraform`: https://github.com/Homebrew/homebrew-core/blob/HEAD/../../../../opt/terraform/.brew/terraform.rb Fall back to the formula's local path in that case, matching the existing behaviour for formulae with no tap.
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.
When a formula has been removed from its tap but is still installed (e.g.
terraform, which was disabled on 2025-04-04 and later removed fromhomebrew-core),FromKegLoaderloads it from the keg's.brew/<name>.rbwith the tap still set from the install receipt.github_infothen built a "From:" URL by joining the tap's GitHub remote withformula.path.relative_path_from(tap.path), producing a path full of../components:Before:
After:
The fix falls back to the formula's local path when its file is not inside its tap's directory, matching the existing behaviour for formulae with no tap (or no remote). The
"#{tap.path}/"(with trailing/) containment check is the same idiom already used indev-cmd/pr-pull.rbandcask/artifact/symlinked.rb.brew lgtm(style, typechecking and tests) with your changes locally?Cursor (Claude Opus 4.7) was used to investigate the root cause, propose the fix, and draft the tests under my direction and review. I verified end-to-end that
brew info terraformnow prints the local path (and thatbrew info gitstill prints the correct GitHub URL for a formula present in its tap), and ranbrew style,brew typecheck, andbrew tests --only=cmd/infolocally.