Upgrade all the casks installed via Homebrew Cask

Solution 1:

There is now finally an official upgrade mechanism for Homebrew Cask (see Issue 3396 for the implementation)! To use it, simply run this command:

brew upgrade --cask

However this will not update casks that do not have versioning information (version :latest) or applications that have a built-in upgrade mechanism (auto_updates true). To reinstall these casks (and consequently upgrade them if upgrades are available), run the upgrade command with the --greedy flag like this:

brew upgrade --cask --greedy

Solution 2:

homebrew-cask-upgrade

I think this is by far the best solution to upgrade the casks.
source: https://github.com/buo/homebrew-cask-upgrade

Installation & usage

brew tap buo/cask-upgrade
brew update
brew cu

(Optional) Force upgrade outdated apps including the ones marked as latest:

brew cu --all

Solution 3:

It is possible to list the installed casks with:

brew cask list

And force the re-installation of a cask with:

brew cask install --force CASK_NAME

So piping the output of the first command into the second, we update all the casks:

brew cask list | xargs brew cask install --force

Solution 4:

Bash script to upgrade packages

inspired by Pascal answer

#!/usr/bin/env bash

(set -x; brew update;)

(set -x; brew cleanup;)
(set -x; brew cask cleanup;)

red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`

casks=( $(brew cask list) )

for cask in ${casks[@]}
do
    version=$(brew cask info $cask | sed -n "s/$cask:\ \(.*\)/\1/p")
    installed=$(find "/usr/local/Caskroom/$cask" -type d -maxdepth 1 -maxdepth 1 -name "$version")

    if [[ -z $installed ]]; then
        echo "${red}${cask}${reset} requires ${red}update${reset}."
        (set -x; brew cask uninstall $cask --force;)
        (set -x; brew cask install $cask --force;)
    else
        echo "${red}${cask}${reset} is ${green}up-to-date${reset}."
    fi
done

What it does

  • update brew/brew cask, cleanup
  • read the casks list
  • check the brew cask info for the newest version
  • install new version if available (and removes all old versions!)

source: https://gist.github.com/atais/9c72e469b1cbec35c7c430ce03de2a6b

one liner for impatient:

curl -s https://gist.githubusercontent.com/atais/9c72e469b1cbec35c7c430ce03de2a6b/raw/36808a0544628398f26b48f7a3c7b309872ca2c6/cask_upgrade.sh | bash /dev/stdin

save as /usr/local/bin/cask-upgrade, so you can run it locally as cask-upgrade later