Skip to content

cask/upgrade: re-register application bundle before reopen#22425

Merged
MikeMcQuaid merged 1 commit into
mainfrom
register-bundle
May 27, 2026
Merged

cask/upgrade: re-register application bundle before reopen#22425
MikeMcQuaid merged 1 commit into
mainfrom
register-bundle

Conversation

@bevanjkay
Copy link
Copy Markdown
Member

After a cask upgrade installs a new app bundle, open -b <bundle_id> can fail with LSCopyApplicationURLsForBundleIdentifier() failed because Launch Services hasn't re-indexed the new bundle yet.

Fix this by running lsregister on each newly installed .app artifact before attempting to reopen by bundle ID. This forces synchronous LS re-registration and has negligible overhead relative to the preceding download and install. Note: this only applies to app stanzas.

In testing this does not extend the time it takes to run brew upgrade an discernible amount.


  • 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? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

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

I used claude-code to help implement the registration of the replaced application.


Copilot AI review requested due to automatic review settings May 27, 2026 00:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 aims to make brew upgrade --cask more reliable when reopening applications by bundle ID after an upgrade, by forcing Launch Services to re-index newly installed .app bundles before running open -b <bundle_id>.

Changes:

  • Update reopen_apps_after_upgrade to accept both old_cask and new_cask.
  • Add a Launch Services re-registration step for newly installed app artifacts prior to reopening.
  • Update the upgrade_cask call site to pass new_cask into the reopen helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/cask/upgrade.rb Outdated
Comment thread Library/Homebrew/cask/upgrade.rb Outdated
Comment thread Library/Homebrew/cask/upgrade.rb
Copy link
Copy Markdown
Member

@p-linnane p-linnane left a comment

Choose a reason for hiding this comment

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

Makes sense, thanks!

Copy link
Copy Markdown
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 added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit f2c2b78 May 27, 2026
72 of 76 checks passed
@MikeMcQuaid MikeMcQuaid deleted the register-bundle branch May 27, 2026 08:00
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.

4 participants