Skip to content

Comments

cask: gracefully handle removed DSL methods#21624

Open
costajohnt wants to merge 1 commit intoHomebrew:mainfrom
costajohnt:fix/appcast-uninstall-error
Open

cask: gracefully handle removed DSL methods#21624
costajohnt wants to merge 1 commit intoHomebrew:mainfrom
costajohnt:fix/appcast-uninstall-error

Conversation

@costajohnt
Copy link
Contributor

Summary

Casks installed before the appcast stanza was removed from the Cask DSL cannot be managed (brew uninstall, brew upgrade, brew info) because loading the cached .rb caskfile triggers method_missing, which calls ofail and sets Homebrew.failed = true.

This adds a REMOVED_METHODS constant to Cask::DSL containing known removed stanza names (currently appcast). 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 like uninstall to succeed.

Before: brew uninstall --cask qlimagesizeError: Unexpected method 'appcast' called on Cask qlimagesize.
After: brew uninstall --cask qlimagesizeWarning: 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

  • Added RSpec tests verifying removed methods produce a warning (not an error) and do not set Homebrew.failed
  • Existing test for unknown methods still correctly triggers ofail
  • brew tests --only cask/dsl passes (all specs green)
  • brew style passes on the changed file

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
@costajohnt costajohnt force-pushed the fix/appcast-uninstall-error branch from 008a6c0 to 8e30488 Compare February 24, 2026 22:34
@costajohnt costajohnt marked this pull request as ready for review February 24, 2026 22:59
Copy link
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 @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!

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.

Cannot uninstall/upgrade casks installed with removed 'appcast' method

2 participants