KEMBAR78
Revert "Revert "Use installed keg formula files when referencing installed formulae/dependencies"" by Rylan12 · Pull Request #20819 · Homebrew/brew · GitHub
Skip to content

Conversation

@Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Oct 5, 2025

Reverts #20753

Retry #20603. The differenes between this PR and the previous attempt can be viewed in 04450cf (#20819)

The issue was that brew bottle loads a formula from the path /opt/homebrew/opt/foo/.brew/foo.rb, but that doesn't include tap information. We write the tap information to the formula tab, so the information is indeed available.

Now, inside FromPathLoader, if we detect that the path is a keg path, use FromKegLoader instead, which reads information from the tab and fills the tap information correctly.


I double checked that this works with the following:

$ brew install --build-bottle hello
==> Fetching downloads for: hello
✔︎ API Source hello.rb
✔︎ Formula hello (2.12.2)
==> ./configure --disable-silent-rules
==> make install
==> Not running 'post_install' as we're building a bottle
You can run it manually using:
  brew postinstall hello
🍺  /opt/homebrew/Cellar/hello/2.12.2: 56 files, 355.0KB, built in 30 seconds
==> Running `brew cleanup hello`...

$ brew bottle --json hello --only-json-tab
==> Determining hello bottle rebuild...
==> Bottling hello--2.12.2.arm64_tahoe.bottle.tar.gz...
./hello--2.12.2.arm64_tahoe.bottle.tar.gz
  bottle do
    sha256 arm64_tahoe: "45b9d5dbc87e6cf7509c4e5e099ff7889d65c1e1710c2ef57d1e3d9b5896deaf"
  end

$ brew bottle --merge --write --no-commit --no-all-checks ./hello*.json
==> hello
  bottle do
    sha256 arm64_tahoe: "45b9d5dbc87e6cf7509c4e5e099ff7889d65c1e1710c2ef57d1e3d9b5896deaf"
  end

return unless path.expand_path.exist?
return unless ::Utils::Path.loadable_package_path?(path, :formula)

# If the path is for an installed keg, use FromKegLoader instead
Copy link
Member

Choose a reason for hiding this comment

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

Totally fine to merge as-is for now but feels like ideally FromKegLoader would be higher in the load order and be detected as an option before FromPathLoader?

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

Thanks!

@MikeMcQuaid MikeMcQuaid enabled auto-merge October 6, 2025 08:18
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Oct 6, 2025
Merged via the queue into main with commit 77824d2 Oct 6, 2025
45 checks passed
@MikeMcQuaid MikeMcQuaid deleted the revert-20753-revert-20603-install-uninstall-formulae-internal-api branch October 6, 2025 08:43
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