14

I have a Homebrew cask installed which, when I attempt to uninstall it gives me an error:

$ brew cask uninstall julia
Error: Cask 'julia' definition is invalid: invalid 'depends_on macos' value: ":lion"

This leaves me unable to use brew to remove the files installed by the cask or undo the other changes the cask installation processes made.

How do I manually remove a cask, and reverse the ranges that were made when it was installed?


$ brew cask info julia
julia: 1.1.0
https://julialang.org/
/usr/local/Caskroom/julia/0.5.0 (64B)
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/julia.rb
==> Name
Julia
==> Artifacts
Julia-1.1.app (App)
/Applications/Julia-1.1.app/Contents/Resources/julia/bin/julia (Binary)

$ brew cask outdated julia
julia (0.5.0) != 1.1.0

brew cask reinstall julia
==> Satisfying dependencies
==> Downloading https://julialang-s3.julialang.org/bin/mac/x64/1.1/julia-1.1.0-mac64.dmg
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'julia'.
Error: Cask 'julia' definition is invalid: invalid 'depends_on macos' value: ":lion"

4 Answers 4

13

I had this problem, and was able to manage it by running the command in the first post at https://github.com/Homebrew/homebrew-cask/issues/58046 -- which is:

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

According to that post:

This will remove all depends_on macos references of installed casks (where it doesn’t matter anymore anyway).

2
  • Thank you! This really helped solved an issue I was having trying to update wkhtmltopdf on Big Sur. Commented Aug 25, 2020 at 16:49
  • This worked for me too. Followed up with brew uninstall julia and capiche.
    – Willy
    Commented Sep 20, 2020 at 23:42
12

Try updating it, cleaning it, then forcing the uninstall.

brew update

brew cleanup

rm -rf /opt/homebrew-cask/Caskroom/julia

You may need to use sudo to get the last one to work

2
  • 1
    Error: invalid option: --force
    – orome
    Commented May 6, 2019 at 19:23
  • for me the directory was rather present at: /opt/homebrew/Caskroom/ Commented May 6 at 16:22
5

now the route its /opt/homebrew/Caskroom. ex.

rm -rf /opt/homebrew/Caskroom/fig

0

This can also happen if you have removed the cask manually

...by dragging it to the trash in Finder. If the cask has an "uninstall script", brew will attempt to use the application's uninstall script and it will be missing. This creates a loop.

example:

iMac191 ~ brew uninstall vnc-server
==> Uninstalling Cask vnc-server
Error: Failure while executing; `/usr/bin/sudo -E -- /Applications/RealVNC/Uninstall\ VNC\ Server.app/Contents/Resources/uninstaller.sh` exited with 1. Here's the output:
sudo: /Applications/RealVNC/Uninstall VNC Server.app/Contents/Resources/uninstaller.sh: command not found

force reinstall will also not work:

14:54:14.415 at iMac191 ~ brew reinstall vnc-server --force
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/14c13ca76d167bec41a6ec6e2289aff95d07beee/Casks/v/vnc-server.rb
Already downloaded: /Users/john/Library/Caches/Homebrew/downloads/f00ae7966eb12eeb9ed9de89427afeb91dbab4a8b36312e86f7ce4432675f3be--vnc-server.rb
==> Downloading https://downloads.realvnc.com/download/file/vnc.files/VNC-Server-7.7.0-MacOSX-universal.pkg
Already downloaded: /Users/john/Library/Caches/Homebrew/downloads/4745123e74b208aefd15a3e7f63b58dd1a9da534e2fc44128b6e8ad8f8c8a151--VNC-Server-7.7.0-MacOSX-universal.pkg
==> Uninstalling Cask vnc-server
Password:
Error: Failure while executing; `/usr/bin/sudo -E -- /Applications/RealVNC/Uninstall\ VNC\ Server.app/Contents/Resources/uninstaller.sh` exited with 1. Here's the output:
sudo: /Applications/RealVNC/Uninstall VNC Server.app/Contents/Resources/uninstaller.sh: command not found

The only option is to manually remove:

homebrew on Apple Silicon:
rm -rf /opt/homebrew-cask/Caskroom/vnc-server

homebrew on Intel:
rm -rf /usr/local/Caskroom/vnc-server

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