23

Using Homebrew's brew command, I would like to remove some specific versions of a formula and keep others.

I know that I can use brew cleanup to remove all old versions but this isn't exactly what I want. Cleanup will remove all the old versions, but I wish to keep one of them.

To be specific, I have the following versions of a package installed: * 2.10.3 * 2.10.4 * 2.11.0 * 2.11.1

I would like to keep the current version, right now that's 2.11.1 and also keep version 2.10.4. I would like to remove the other versions, 2.11.0 and 2.10.3.

Carl
  • 766
  • 5
  • 14
  • btw, I did see this link http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula?rq=1 which seems somewhat related but I failed to join the dots on solving my specific situation. – Carl May 30 '14 at 15:05

2 Answers2

35

To remove all old versions:

brew cleanup

To remove old version of X package:

brew cleanup X
19

You can just rm -rf them from the Cellar.

mipadi
  • 359,228
  • 81
  • 502
  • 469
  • 3
    Not really. I also had to `brew prune` and `brew link ` to have executables available. – ciastek May 04 '16 at 16:16
  • 2
    @ciastek: You have to do that if you're removing the currently active version, in which case it's better to do `brew rm && brew ln `. – mipadi May 04 '16 at 17:01
  • @mipadi And how do I remove from the `Cellar` ? – p.matsinopoulos Feb 15 '17 at 06:39
  • 1
    I tried this, and now I'm getting this error `Error: /usr/local/Cellar/python/3.7.0 is not a directory`. I pinned python 3.6.5_1 and did `brew switch python 3.6.5_1`, then removed the 3.7.0 directory. Any way to remove 3.7.0 and not break brew? – Christian Long Jul 10 '18 at 17:39