Skip to content

Pass the download queue to FormulaInstaller when upgrading - #23416

Merged
MikeMcQuaid merged 1 commit into
mainfrom
inject-upgrade-download-queue
Aug 4, 2026
Merged

Pass the download queue to FormulaInstaller when upgrading#23416
MikeMcQuaid merged 1 commit into
mainfrom
inject-upgrade-download-queue

Conversation

@p-linnane

Copy link
Copy Markdown
Contributor

FormulaInstaller#initialize memoized Homebrew.default_download_queue before the upgrade path replaced the installer's queue through its accessor. In tests that let a stubbed Homebrew::DownloadQueue.new double become the process-global default queue, which at_exit then called shutdown on after RSpec had torn down its mock lifecycle. Several tests (generic OS) runs failed this way: every example passed, then the process exited 1 with RSpec::Mocks::OutsideOfExampleError in Homebrew.shutdown_default_download_queue.

FormulaInstaller now takes an optional download_queue: that defaults to Homebrew.default_download_queue, so every existing caller is unchanged. Upgrade.formula_installers passes 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.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

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.


Signed-off-by: Patrick Linnane <patrick@linnane.io>
Copilot AI review requested due to automatic review settings August 3, 2026 21:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 to FormulaInstaller#initialize, defaulting to Homebrew.default_download_queue.
  • Pass the upgrade-owned download_queue into FormulaInstaller during Upgrade.formula_installers construction (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.

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Aug 4, 2026
Merged via the queue into main with commit 09a44e5 Aug 4, 2026
44 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the inject-upgrade-download-queue branch August 4, 2026 08:55
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