51

I can't uninstall or upgrade some casks due to a definition error.

F.e. if I run update or upgrade:

brew cask upgrade the-unarchiver  
Error: Cask 'the-unarchiver' definition is invalid: invalid 'depends_on macos' value: ":lion"

brew cask uninstall the-unarchiver 
Error: Cask 'the-unarchiver' definition is invalid: invalid 'depends_on macos' value: ":lion"

I've tried to see if there's something I can edit in the formula but I didn't find anything related to this error.

cask 'the-unarchiver' do
  version '4.1.0,121:1549634528'
  sha256 'ff97b168f07d084e88f48e5d1e5202445596acd6eec39685d28910ee71d3a74b'

  # devmate.com/com.macpaw.site.theunarchiver was verified as official when first introduced to the cask
  url "https://dl.devmate.com/com.macpaw.site.theunarchiver/#{version.after_comma.before_colon}/#{version.after_colon}/TheUnarchiver-#{version.after_comma.before_colon}.zip"
  appcast 'https://updates.devmate.com/com.macpaw.site.theunarchiver.xml'
  name 'The Unarchiver'
  homepage 'https://theunarchiver.com/'

  auto_updates true

  app 'The Unarchiver.app'

  zap trash: [
               '~/Library/Caches/cx.c3.theunarchiver',
               '~/Library/Cookies/cx.c3.theunarchiver.binarycookies',
               '~/Library/Preferences/cx.c3.theunarchiver.plist',
               '~/Library/Saved Application State/cx.c3.theunarchiver.savedState',
             ]
end

1 Answer 1

100

Homebrew cask developers deleted pre-maverics dependencies support due to the high maintenance overhead and it looks like they introduced a bug.

The way to fix it is to run:

/usr/bin/find "$(brew --prefix)/Caskroom/"*'/.metadata' -type f -name '*.rb' -print0 | /usr/bin/xargs -0 /usr/bin/perl -i -0pe 's/depends_on macos: \[.*?\]//gsm;s/depends_on macos: .*//g'

You can find this solution, the reason for this error and more info in:

https://github.com/Homebrew/homebrew-cask/issues/58046

4
  • 25
    FWIW this also seems to work for other broken dependencies, e.g. brew uninstall wine-stable Error: Cask 'wine-stable' definition is invalid: invalid depends_on key: ':x11' -> /usr/bin/find "$(brew --prefix)/Caskroom/"*'/.metadata' -type f -name '*.rb' -print0 | /usr/bin/xargs -0 /usr/bin/perl -i -0pe 's/depends_on x11: \[.*?\]//gsm;s/depends_on x11: .*//g' -> uninstall succeeds now
    – nmr
    Jun 26, 2021 at 18:11
  • 4
    @nmr Thank you! This is what I was looking for. Also was unable to uninstall Wine.
    – pratt
    Aug 9, 2021 at 10:00
  • this seems to have also worked for me, thanks!
    – davidawad
    Oct 26, 2021 at 4:35
  • Did NOT work on my macOS 10.14 system. Apr 11, 2022 at 4:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.