Pass the download queue to FormulaInstaller when upgrading - #23416
Merged
Conversation
Signed-off-by: Patrick Linnane <patrick@linnane.io>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an upgrade-path interaction between FormulaInstaller initialisation and the download queue: the installer previously eagerly memoised Homebrew.default_download_queue even when the upgrade flow immediately replaced fi.download_queue, which could cause at_exit shutdown of an RSpec double after mock teardown. The change makes the download queue an injectable (optional) keyword argument so the upgrade pipeline can pass its owned queue and avoid touching the global default.
Changes:
- Add
download_queue:keyword argument toFormulaInstaller#initialize, defaulting toHomebrew.default_download_queue. - Pass the upgrade-owned
download_queueintoFormulaInstallerduringUpgrade.formula_installersconstruction (removing the post-init accessor reassignment). - Add a regression spec asserting the upgrade installer construction does not call
Homebrew.default_download_queue.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Library/Homebrew/upgrade.rb | Pass the local upgrade download queue into FormulaInstaller instead of initialising the global default and then overriding via accessor. |
| Library/Homebrew/formula_installer.rb | Accept an optional injected download_queue: (defaulting to the global default) and assign it directly. |
| Library/Homebrew/test/cmd/upgrade_spec.rb | Add a regression expectation preventing Homebrew.default_download_queue use in the bottle manifest prefetch path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
FormulaInstaller#initializememoizedHomebrew.default_download_queuebefore the upgrade path replaced the installer's queue through its accessor. In tests that let a stubbedHomebrew::DownloadQueue.newdouble become the process-global default queue, whichat_exitthen calledshutdownon after RSpec had torn down its mock lifecycle. Severaltests (generic OS)runs failed this way: every example passed, then the process exited 1 withRSpec::Mocks::OutsideOfExampleErrorinHomebrew.shutdown_default_download_queue.FormulaInstallernow takes an optionaldownload_queue:that defaults toHomebrew.default_download_queue, so every existing caller is unchanged.Upgrade.formula_installerspasses the queue it already owns and no longer initializes or replaces the global default. Upgrades also stop allocating a default queue thread pool they never use.Reproduce with
./bin/brew tests --only=cmd/upgrade:1004 --seed=32372, which reports one passing example and then exits 1 without this change.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Code (Opus 5) drafted the implementation and tests; I reviewed the diff, verified the new test fails without the fix and passes with it, and ran
brew lgtm+ targeted specs.