KEMBAR78
extend/os/mac/reinstall: fix pkgconf reinstall by ZhongRuoyu · Pull Request #20692 · Homebrew/brew · GitHub
Skip to content

Conversation

ZhongRuoyu
Copy link
Member

@ZhongRuoyu ZhongRuoyu commented Sep 15, 2025

  • 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?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Before:

$ rm `brew --cache`/downloads/*pkgconf*
$ gsed -Ei 's/macOS [[:digit:]]+/macOS 14/g' `brew --prefix pkgconf`/INSTALL_RECEIPT.json
$ brew up
==> Updating Homebrew...
Already up-to-date.
Error: wrong number of arguments (given 2, expected 0)
Warning: Removed Sorbet lines from backtrace!
Rerun with `--verbose` to see the original backtrace
/opt/homebrew/Library/Homebrew/reinstall.rb:67:in 'BasicObject#initialize'
/opt/homebrew/Library/Homebrew/reinstall.rb:67:in 'Class#new'
/opt/homebrew/Library/Homebrew/reinstall.rb:67:in 'Homebrew::Reinstall.build_install_context'
/opt/homebrew/Library/Homebrew/extend/os/mac/reinstall.rb:27:in 'OS::Mac::Reinstall::ClassMethods#reinstall_pkgconf_if_needed!'
/opt/homebrew/Library/Homebrew/cmd/update-report.rb:258:in 'Homebrew::Cmd::UpdateReport#output_update_report'
/opt/homebrew/Library/Homebrew/cmd/update-report.rb:34:in 'Homebrew::Cmd::UpdateReport#run'
/opt/homebrew/Library/Homebrew/brew.rb:101:in '<main>'
Please report this issue:
  https://docs.brew.sh/Troubleshooting

There are two problems here:

  1. We don't require formula_installer in reinstall.rb, and it isn't required indirectly anywhere else, so FormulaInstaller is undefined.
  2. We don't fetch the pkgconf bottle before trying to reinstall it, so the reinstall fails because the bottle isn't available.

We fix 2. by fetching the formula before attempting to reinstall it. Then, at the same time, by sourcing install, we also fix 1.

After:

$ brew up
==> Updating Homebrew...
Already up-to-date.
==> Fetching downloads for: pkgconf
✔︎ Bottle Manifest pkgconf (2.5.1)
==> Verifying attestation for pkgconf
✔︎ Bottle pkgconf (2.5.1)
==> Reinstalling pkgconf
==> Pouring pkgconf--2.5.1.arm64_tahoe.bottle.tar.gz
🍺  /opt/homebrew/Cellar/pkgconf/2.5.1: 28 files, 519.8KB
==> Reinstalled pkgconf due to macOS version mismatch

@ZhongRuoyu ZhongRuoyu force-pushed the fix-pkgconf-reinstall branch 2 times, most recently from eb12257 to e3e0d21 Compare September 15, 2025 21:10
Before:

    $ rm `brew --cache`/downloads/*pkgconf*
    $ gsed -Ei 's/macOS [[:digit:]]+/macOS 14/g' `brew --prefix pkgconf`/INSTALL_RECEIPT.json
    $ brew up
    ==> Updating Homebrew...
    Already up-to-date.
    Error: wrong number of arguments (given 2, expected 0)
    Warning: Removed Sorbet lines from backtrace!
    Rerun with `--verbose` to see the original backtrace
    /opt/homebrew/Library/Homebrew/reinstall.rb:67:in 'BasicObject#initialize'
    /opt/homebrew/Library/Homebrew/reinstall.rb:67:in 'Class#new'
    /opt/homebrew/Library/Homebrew/reinstall.rb:67:in 'Homebrew::Reinstall.build_install_context'
    /opt/homebrew/Library/Homebrew/extend/os/mac/reinstall.rb:27:in 'OS::Mac::Reinstall::ClassMethods#reinstall_pkgconf_if_needed!'
    /opt/homebrew/Library/Homebrew/cmd/update-report.rb:258:in 'Homebrew::Cmd::UpdateReport#output_update_report'
    /opt/homebrew/Library/Homebrew/cmd/update-report.rb:34:in 'Homebrew::Cmd::UpdateReport#run'
    /opt/homebrew/Library/Homebrew/brew.rb:101:in '<main>'
    Please report this issue:
      https://docs.brew.sh/Troubleshooting

There are two problems here:
1. We don't require `formula_installer` in `reinstall.rb`, and it isn't
   required indirectly anywhere else, so `FormulaInstaller` is
   undefined.
2. We don't fetch the `pkgconf` bottle before trying to reinstall it, so
   the reinstall fails because the bottle isn't available.

We fix 2. by fetching the formula before attempting to reinstall it.
Then, at the same time, by sourcing `install`, we also fix 1.

After:

    $ brew up
    ==> Updating Homebrew...
    Already up-to-date.
    ==> Fetching downloads for: pkgconf
    ✔︎ Bottle Manifest pkgconf (2.5.1)
    ==> Verifying attestation for pkgconf
    ✔︎ Bottle pkgconf (2.5.1)
    ==> Reinstalling pkgconf
    ==> Pouring pkgconf--2.5.1.arm64_tahoe.bottle.tar.gz
    🍺  /opt/homebrew/Cellar/pkgconf/2.5.1: 28 files, 519.8KB
    ==> Reinstalled pkgconf due to macOS version mismatch
@ZhongRuoyu ZhongRuoyu force-pushed the fix-pkgconf-reinstall branch from e3e0d21 to 5f9182c Compare September 15, 2025 21:45
@ZhongRuoyu ZhongRuoyu added this pull request to the merge queue Sep 16, 2025
Merged via the queue into main with commit 5988bfc Sep 16, 2025
36 checks passed
@ZhongRuoyu ZhongRuoyu deleted the fix-pkgconf-reinstall branch September 16, 2025 03:53
@MikeMcQuaid
Copy link
Member

Thanks for the quick fix @ZhongRuoyu!

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.

3 participants