Skip to content

info: avoid broken GitHub URL for removed formulae#22062

Merged
MikeMcQuaid merged 1 commit intoHomebrew:mainfrom
bayandin:path-for-deleted-formulae
Apr 22, 2026
Merged

info: avoid broken GitHub URL for removed formulae#22062
MikeMcQuaid merged 1 commit intoHomebrew:mainfrom
bayandin:path-for-deleted-formulae

Conversation

@bayandin
Copy link
Copy Markdown
Contributor

@bayandin bayandin commented Apr 22, 2026

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 from homebrew-core), 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:

Before:

$ brew info terraform
...
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/../../../../opt/terraform/.brew/terraform.rb

After:

$ brew info terraform
...
From: /opt/homebrew/opt/terraform/.brew/terraform.rb

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 in dev-cmd/pr-pull.rb and cask/artifact/symlinked.rb.


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes. Non-maintainers may only have one AI-assisted/generated PR open at a time.

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 terraform now prints the local path (and that brew info git still prints the correct GitHub URL for a formula present in its tap), and ran brew style, brew typecheck, and brew tests --only=cmd/info locally.

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.
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Apr 22, 2026
Merged via the queue into Homebrew:main with commit be86fdf Apr 22, 2026
54 of 56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants