Reputation: 5762
When I install a package through homebrew, it removes the old versions.
$ brew upgrade terraform
🍺 /usr/local/Cellar/terraform/0.11.14: 6 files, 42.4MB
Removing: /usr/local/Cellar/terraform/0.11.13... (6 files, 120.6MB)
Removing: /Users/vikas/Library/Caches/Homebrew/terraform--0.11.13.mojave.bottle.tar.gz... (25.4MB)
How can I disable this so that I can switch back to older versions.
$ brew switch [formula] [version]
Upvotes: 13
Views: 63018
Reputation: 585
That looks weird because usually homebrew does not actually delete old versions right away, it usually keeps them so you can switch back later. Except maybe you have been doing brew cleanup
.
If you have not been removing the older versions, then you have a chance for some older version of your programs to be there inactive. You can simply reactivate those previous versions using brew switch
to brew older versions. e.g.
$ brew info mysql (to get info about the installed versions)
$ brew switch mysql 5.7.21 (to switch to a stable version)
Alternatively, you use force like so: e.g.
brew link --force [email protected]
EXCEPT you are using 2.0, then YES, This happens as-of 2.0.0., auto cleanup is default. Use man brew
and see how to opt-out of this behavior.
Checkout brew --force
in man brew
Upvotes: 2
Reputation: 5762
This behavior can be avoided by setting a variable export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
in ~/.bashrc
or ~/.zshrc
(or specific to your shell).
Once done, you can check whether it has been applied correctly by:
$ brew config | grep HOMEBREW_NO_INSTALL_CLEANUP
HOMEBREW_NO_INSTALL_CLEANUP: TRUE
$
This was introduced in v1.9.0 and has been documented in man brew
as well, but is easy to miss :)
Unless HOMEBREW_NO_INSTALL_CLEANUP is set, brew cleanup will be run for the installed formulae or, every 30 days, for all formulae
References: - https://github.com/Homebrew/brew/issues/5654
Upvotes: 33