Configure Homebrew to not delete old versions

When I install a package through homebrew, it removes the old versions automatically.

$ 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]

I am running v2.2.1

$ brew --version
Homebrew 2.1.2
Homebrew/homebrew-core (git revision cf0ae; last commit 2019-05-18)
Homebrew/homebrew-cask (git revision f1fbc; last commit 2019-05-18)

Did you check man brew?

         If set, brew install, brew upgrade and brew reinstall will never
         automatically  cleanup the installed/upgraded/reinstalled formu-
        lae or all formulae every 30 days.
1 Like

Thanks for that, I did have a look at it but looks like I missed this variable. I have now found a similar issue on GitHub as well.