9

I am using homebrew-cask to keep my ecosystem of applications up-to-date. It is great when maintaining several computers at home, travel or on the go.

However, when some packages are getting updated (such as Google Chrome), I end up having different concurrent versions installed (and which are seen by the OS):

$ ls /opt/homebrew-cask/Caskroom/google-chrome/ latest stable-channel

This happens when upgrading a cask:

$ ls -l /opt/homebrew-cask/Caskroom/tunnelblick
total 0
drwxr-xr-x 5 foo staff 238 Mar 11 07:42 3.3.0
drwxr-xr-x 5 foo staff 238 May 13 13:53 3.3.2
[13:00:40] foo at bar in ~
$ brew cask install --force tunnelblick
==> Caveats
For security reasons, Tunnelblick must be installed to /Applications and will request to be moved at launch.

==> Downloading https://downloads.sourceforge.net/project/tunnelblick/All%20files/Tunnelblick_3.3.4.dmg
######################################################################## 100.0%
==> It seems there is already an App at '/Applications/Tunnelblick.app'; not linking.
🍺  tunnelblick installed to '/opt/homebrew-cask/Caskroom/tunnelblick/3.3.4' (236 files, 20M)

$ ls -l /opt/homebrew-cask/Caskroom/tunnelblick
total 0
drwxr-xr-x 5 foo staff 238 Mar 11 07:42 3.3.0
drwxr-xr-x 5 foo staff 238 May 13 13:53 3.3.2
drwxr-xr-x 5 foo staff 238 Jun 26 13:01 3.3.4
[13:01:26] foo at bar in ~

How do I only keep the most recent?

  • have you tried brew cleanup and brew prune? – dwightk Jun 21 '14 at 13:13
  • yes I tried but it does not apply to casks... – meduz Jun 26 '14 at 11:20
  • 1
    This is apparently discussed @ github.com/caskroom/homebrew-cask/issues/309 – meduz Sep 1 '14 at 12:10
  • Still looking for an answer. My latest attempts involve removing all applications and reinstalling, not very ecological. – meduz Sep 15 '16 at 20:31
1

In Terminal, type:

for app in $(brew cask list); do cver="$(brew cask info "${app}" | head -n 1 | cut -d " " -f 2)"; ivers=$(ls -1 "/opt/homebrew-cask/Caskroom/${app}/.metadata/" | tr '\n' ' ' | sed -e 's/ $//'); aivers=(${ivers}); nvers=$(echo ${#aivers[@]}); echo "[*] Found ${app} in cask list. Latest available version is ${cver}. You have installed version(s): ${overs}"; if [[ ${nvers} -eq 1 ]]; then echo "${ivers}" | grep -q "^${cver}$" && { echo "[*] Latest version already installed :) Skipping changes ..."; continue; }; fi; echo "[+] Fixing from ${ivers} to ${cver} ..."; brew cask uninstall "${app}" --force; brew cask install "${app}"; done

Hint: Copy and paste the above command line into Terminal.

  • and don't give the same answer to more than one question. If questions are answered the same then the question should be flagged/closed as a duplicate – Mark Apr 28 '16 at 9:28
  • hi @name, could you edit your answer to know what it does, seems cryptic (my quote of the day: "stackoverflow is not about solutions, but about answers" :-) ) – meduz Apr 30 '16 at 12:43
  • To the individuals that keep trying to edit this post changing the given complex command line in to a script, please stop! The author wrote it as a complex command line, not a script. Please respect the authors decision to post it as a complex command line, not a script! – user3439894 May 1 '16 at 0:19
  • Remember with the new Homebrew Caskroom location you need to change /opt/homebrew-cask/Caskroom/ to /usr/local/Caskroom/. – Spotlight Jul 9 '16 at 19:48
  • Just an FYI for those running this in future, it seems it's uninstalling/reinstalling all of my casks. Doesn't seem to properly detect my installed version? "[*] Found atom in cask list. Latest available version is 1.11.2. You have installed version(s):" – devalias Nov 1 '16 at 22:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .