cask: gracefully handle removed DSL methods by costajohnt · Pull Request #21624 · Homebrew/brew
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
Move error handling from DSL method_missing (opoo/ofail) to the loader level. Unknown DSL methods now raise NoMethodError, which Cask#refresh converts to CaskInvalidError. This lets the existing fallback infrastructure in named_args.rb handle it gracefully for uninstall/upgrade operations.
Remove unreachable `if method` guard in DSL#method_missing (Ruby's method_missing always receives a Symbol, which is always truthy). Combine test assertions so the Homebrew.failed check also verifies the exception is raised.
…files When loading an installed caskfile that contains removed DSL methods, wrap the resulting CaskInvalidError as CaskUnreadableError so the existing fallback in named_args.rb can handle it gracefully. This is gated on @from_installed_caskfile to avoid affecting normal cask loading, following the same pattern as formulary.rb.
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