cask: gracefully handle removed DSL methods#21624
Open
costajohnt wants to merge 1 commit intoHomebrew:mainfrom
Open
cask: gracefully handle removed DSL methods#21624costajohnt wants to merge 1 commit intoHomebrew:mainfrom
costajohnt wants to merge 1 commit intoHomebrew:mainfrom
Conversation
Casks installed before `appcast` was removed from the DSL cannot be managed (uninstall/upgrade/info) because loading the cached .rb caskfile triggers `method_missing`, which calls `ofail` and sets `Homebrew.failed = true`. Add a `REMOVED_METHODS` set to the DSL class. When a removed method is encountered, issue a warning (`opoo`) instead of an error (`ofail`) so the cask still loads cleanly and operations like `uninstall` exit with code 0. Fixes Homebrew#21602
008a6c0 to
8e30488
Compare
MikeMcQuaid
reviewed
Feb 25, 2026
Member
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Thanks @costajohnt! This is good progress but I'm not sure the right approach yet.
ofail sets a failing error code and just prints an Error: message so it's not really doing much different to opoo's Warning: equivalent.
Instead, this should involve changing some logic in cask_loader.rb (see rescue NameError, ArgumentError, ScriptError, MethodDeprecatedError, MacOSVersion::Error in formulary.rb for similar logic) so that we don't try to read invalid casks at all. For certain operations (e.g. no to info, yes to uninstall) we will also need an override in this case so that we can still uninstall even with no readable cask .rb or .json file.
Happy to continue to give feedback or answer questions, thanks!
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.
Summary
Casks installed before the
appcaststanza was removed from the Cask DSL cannot be managed (brew uninstall,brew upgrade,brew info) because loading the cached.rbcaskfile triggersmethod_missing, which callsofailand setsHomebrew.failed = true.This adds a
REMOVED_METHODSconstant toCask::DSLcontaining known removed stanza names (currentlyappcast). When a removed method is encountered during cask loading, a warning (opoo) is issued instead of an error (ofail), allowing the cask to load cleanly and operations likeuninstallto succeed.Before:
brew uninstall --cask qlimagesize→Error: Unexpected method 'appcast' called on Cask qlimagesize.After:
brew uninstall --cask qlimagesize→Warning: Ignoring removed method 'appcast' in Cask qlimagesize.(and the uninstall completes)Fixes #21602
AI Disclosure
This PR was developed with assistance from Claude Code (Anthropic). All code has been reviewed and tested.
Test Plan
Homebrew.failedofailbrew tests --only cask/dslpasses (all specs green)brew stylepasses on the changed file