Skip to content

Auto-update brew before the outdated check - #250

Open
dergachoff wants to merge 2 commits into
Homebrew:mainfrom
dergachoff:fix-outdated-refresh-api-mode
Open

dergachoff wants to merge 2 commits into
Homebrew:mainfrom
dergachoff:fix-outdated-refresh-api-mode

Conversation

@dergachoff

@dergachoff dergachoff commented Sep 26, 2026 •

Copy link
Copy Markdown

What and why

Problem: the Upgrades tab does not show new upgrades until you run brew update in a terminal. Refresh does not help.

Root cause: the list comes from brew info --installed --json=v2.

  • brew info does not trigger Homebrew's auto-update.
  • With the API on (the default), it re-downloads package data only when the cache is 7 days old (DEFAULT_API_STALE_SECONDS in Library/Homebrew/api.rb).
  • The app's brew update step (dd9452a) only runs when HOMEBREW_NO_INSTALL_FROM_API is set.

Fix: run brew outdated --quiet before brew info.

  • outdated is an auto-update command, so Homebrew itself decides when to update.
  • It respects HOMEBREW_NO_AUTO_UPDATE and HOMEBREW_AUTO_UPDATE_SECS, and refreshes API data after 450s. This works in both API and tap modes.
  • Calling brew update --auto-update directly skips those checks, so I replaced it.
  • The brew config check is no longer needed, so I removed it.
  • The test doubles for brew info now answer only info calls.
  • The app's 300s throttle is unchanged.
  • Refresh, Try Again and 鈱楻 run brew update instead, since the user asked for it.

Fixes #235

Validation

  • scripts/test: pass (also passes on base a9920b4)
  • SwiftFormat lint, SwiftLint --strict, BrewUILint, scripts/localize verify: clean
  • xcodebuild test -scheme Brew-Unit with CI flags: pass
  • Refresh tests: user refresh always runs update; launch, stale cache and the refresh after installs run throttled outdated.
  • App smoke test. I set the API cache date 6 days back, then opened the app:
    • 0.4.4: cache stays old (bug)
    • this branch: cache refreshed
    • this branch with HOMEBREW_NO_AUTO_UPDATE=1: cache stays old (setting respected)
  • Not run: scripts/test-ui. The runner was killed before connecting under local ad-hoc signing.

macOS 27.0, Apple silicon, Xcode 27.0 (27A5194q), Swift 6.4.

  • I followed the conventions and workflow, checked for duplicate PRs and kept this change focused.
  • I added regression coverage for bug fixes or explained why automated coverage is impractical, and reported the relevant validation above.

Screenshots

Not applicable. The UI does not change, only how fresh the data behind the list is.

AI assistance

  • AI was used to generate or assist with generating this PR.

Claude Code (Claude Opus 5.5) found the cause, wrote the patch and ran the checks above. Codex (gpt-6-astra) reviewed it. I reported the bug in #235 and reviewed the diff.

`brew info` never triggers Homebrew's auto-update. With the API on it
re-downloads API data only once the cache is 7 days old, so the Upgrades
tab showed what the last terminal `brew update` saw.

Run `brew outdated --quiet` before `brew info` instead of `brew update`
under HOMEBREW_NO_INSTALL_FROM_API only. `outdated` is an auto-update
command, so Homebrew applies HOMEBREW_NO_AUTO_UPDATE, its own update
interval and API refresh interval, in both API and tap modes. The
`brew config` probe that chose between the modes is no longer needed.

Fixes Homebrew#235
Copilot AI lite review requested due to automatic review settings September 26, 2026 03:41

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.

Copilot review overview

馃數 Needs a closer look

Existing installed-package test doubles must support the new outdated --quiet invocation, and the fallback should validate exact command arguments.

Review effort: Lite
Findings: None

What changed in this PR

Updates installed-package refreshes to run brew outdated --quiet before fetching brew info, allowing Homebrew to manage auto-update timing.

Changes:

  • Replaces conditional updates with auto-update-aware brew outdated --quiet.
  • Removes obsolete brew config environment detection.
  • Updates repository wiring, command doubles, and refresh tests.
File Summary
Tests/鈥婤rewRepositoriesTests/鈥婤rewInstalledPackagesTapRefreshTests.swift Tests refresh ordering and throttling; command fallback should reject unexpected arguments.
Tests/鈥婤rewRepositoriesTests/鈥婤rewInstalledPackagesRepositoryTests.swift Updates repository test coverage and command runners.
Tests/鈥婤rewCLITests/鈥婤rewConfigEnvironmentReaderTests.swift Removes obsolete reader tests.
Sources/鈥婤rewServicesTestSupport/鈥婭nstalledPackagesTestSupport.swift Simplifies repository test wiring.
Sources/鈥婤rewServicesTestSupport/鈥婥ommandRunnerDoubles.swift Updates command doubles for installed-package queries.
Sources/鈥婤rewRepositories/鈥婤rewInstalledPackagesRepository.swift Runs brew outdated --quiet before fetching installed package information.
Sources/鈥婤rewCore/鈥婳perations/鈥婬omebrewEnvironmentReading.swift Removes the obsolete environment-reading protocol.
Sources/鈥婤rewCLI/鈥婥onfig/鈥婤rewConfigEnvironmentReader.swift Removes the obsolete configuration reader.

馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@SMillerDev

Copy link
Copy Markdown
Member

Why run brew outdated when what you need is the implicit brew update it runs?

@dergachoff

Copy link
Copy Markdown
Author

This runs on its own, on app launch and after every install. So I kept brew's auto-update rules: calling brew update directly ignores HOMEBREW_NO_AUTO_UPDATE. outdated respects it.

@dergachoff

Copy link
Copy Markdown
Author

But for intentional button press it won't work for those with "no auto" flags. Makes sense to split into outdated for background and update for hotkey/button. On it 馃

@dergachoff

Copy link
Copy Markdown
Author

Pushed 2b19184. Refresh, Try Again and 鈱楻 now run brew update. App launch and the refresh after installs still run outdated, so they follow the user's auto-update settings.

@MikeMcQuaid

Copy link
Copy Markdown
Member

App launch and the refresh after installs still run outdated, so they follow the user's auto-update settings.

Makes no sense to run brew outdated and throw away the results. Run brew update --auto-update or brew update-if-needed instead.

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.

Upgrades tab is stuck in an outdated state

4 participants