Uninstall untrusted casks safely#22946
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Homebrew’s cask uninstall flow to avoid evaluating Ruby cask definitions from untrusted taps when HOMEBREW_REQUIRE_TAP_TRUST is enabled, while still allowing already-installed casks to be removed using recorded install/uninstall metadata (including installed JSON metadata where available).
Changes:
- Teach
NamedArgs#load_formula_or_caskto fall back to an installed-cask representation for “keg-like” cask operations when the tap/cask is untrusted. - Update
Cask::Installer#load_installed_caskfile!to skip loading an untrusted installed Ruby caskfile and instead reconstruct a safe default uninstall artifact set from the cask’s recorded tab uninstall artifacts. - Add command-level specs covering both “skip untrusted installed .rb” and “use installed JSON metadata” uninstall paths.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Library/Homebrew/test/cmd/uninstall_spec.rb | Adds regression tests ensuring uninstall works without evaluating untrusted Ruby caskfiles and prefers installed JSON metadata when present. |
| Library/Homebrew/cli/named_args.rb | Adds a trust-aware fallback to load an installed cask for keg-like operations (e.g., uninstall) when the tap/cask is untrusted. |
| Library/Homebrew/cask/installer.rb | Skips evaluating untrusted installed Ruby caskfiles during uninstall and builds uninstall artifacts from recorded metadata instead. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Avoid evaluating untrusted Ruby cask files during `uninstall` - Keep installed JSON cask metadata usable for default removal - Warn when falling back to recorded uninstall artifacts
c6a2588 to
c7fd467
Compare
8 tasks
p-linnane
approved these changes
Jul 4, 2026
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.
uninstallFixes #22892
Closes #22894
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?OpenAI Codex 5.5 xhigh with local review and testing.