Homebrew-cask: Could "brew cask cleanup" remove older versions?

Created on 14 Feb 2015  路  17Comments  路  Source: Homebrew/homebrew-cask

Hello,
Currently, when I install a new version of a software like this (libreoffice is just an example):

  1. brew cask install libreoffice
  2. brew cask cleanup

I get the new version of the software (if available), but the older version remains with the new one in the Caskroom.

It's not very practical and not consistent with brew cleanup. See man page:

cleanup [--force] [-ns] [formulae]
For all installed or specific formulae, remove any older versions from the cellar

Did I miss something?
Is there some workaround to perform a cleanup of older installed versions?
Is there a way to upgrade a software another way than with my command 1 above?

Most helpful comment

until a fix, is it safe to manually remove the folder for the old version? or is there any way at all to have cask remove it itself? and if removed manually, will there be left any traces in a cask "registry" that there ought to exist the old version as well?

All 17 comments

Hi @Yann-R, you're right on the money and are doing everything correct; the short answer is "not yet." homebrew-cask is very much pre-alpha, and one of the big pieces is properly implementing brew cask upgrade, currently being tracked in #4678. A major part of that is your very concern, proper uninstalling, as noted there and in #4651. It is definitely on everyone's mind!

OK, thank you for those explanations.
Since homebrew-cask works pretty well, I must admit I forgot its pre-alpha status :-)
We'll keep watching the current developments.

until a fix, is it safe to manually remove the folder for the old version? or is there any way at all to have cask remove it itself? and if removed manually, will there be left any traces in a cask "registry" that there ought to exist the old version as well?

@eallik I removed the old version of LibreOffice manually and the new version still seems to work.

Is there any other solutions beside rm manually?

Is there any other solutions beside rm manually?

No, and there won鈥檛 be since we鈥檒l stop keeping old versions.

So there won't have any older versions after I cleanup all existing old versions manually?

Only after we implement https://github.com/caskroom/homebrew-cask/issues/13201. Until now, everything is still the same.

@cybertk & @Yann-R: I have a rudimentary ruby script for updating casks here: https://github.com/troyxmccall/dotfiles/blob/49bbdf9773117d7d7b0704e7add41dc5d3f4ff6c/bin/cask-upgrade

I also have a cask-retire() bash function that only prunes old versions if that's more up(date) your alley: https://github.com/troyxmccall/dotfiles/blob/8ab354f96f1184cbdd3574b3285a7afe89f2d9f3/.functions#L399-L422

@troyxmccall thanks!

Shouldn't this line use __clean-cask instead of clean-cask?

brew cask cleanup 鈭掆垝outdated

This will clean up cached downloads and tracker symlinks. With 鈭掆垝outdated, it only cleans up cached downloads older than 10 days old.

brew cask cleanup && brew cask list --versions

You'll still see old versions installed.

I created an updated version of @troyxmccall's function as a script. https://gist.github.com/jpickwell/afb7bfc8b166b58150b6c311f34ed271

My version also removes the old .metadata directories which tell brew cask which versions are installed. It also handles version sorting correctly.

@jpickwell, that's brilliant!

Probably won't become an official tool, so I made a nice short link: https://j.mp/brew-cask-retire

Please don鈥檛 necropost. Especially in this case, where the script isn鈥檛 necessary at all. brew cask upgrade is very much live and officially supported and it removes old versions when upgrading.

I鈥檝e unlocked since @specious wants to expand on the point of the script.

But please note the script is not officially supported. As such, any problems or doubts arising from its use need to be posted at its source, not on the Caskroom organisation.

If the discussion elongates more, I鈥檒l relock.

@vitorgalvao, I fully appreciate your suggestion to continue further discussion pertaining to the maintenance script made available by @troyxmccall and @jpickwell at the appropriate forum.

I would like to mention that since brew cask upgrade does not effectively remove all versions of old casks left over from before brew cask upgrade was introduced, this is still a relevant topic for people who come from using brew cask since prior to this relatively recent feature becoming available.

Also, it may be necessary in special cases where you installed a new version of an application manually (outside brew cask) over a previously installed cask and then want to manually remove the older installed cask, since you didn't use brew cask upgrade and you also don't want to runbrew cask uninstall because it will remove your installed application. I know this is not the homebrew way, but I've had that happen and then wanted to clean up.

I'd like to propose to leave this discussion open in good faith that potential participants be respectful and contribute prudently. Locking the topic prevents other contributors from being able to react to a point already made or to provide a different perspective that none of the existing contributors have possibly considered.

Was this page helpful?
0 / 5 - 0 ratings