I work with several clients and often we are using different version of tools at different times. While I’m endeavouring to move my development processes to use docker containers I still do a lot of development locally on my Mac. I’m still running Mac OS (or is that OS X??), and so I use brew to install many of my tools.
What I’ve struggled with in the past is installing certain versions of the many tools. e.g. terraform or ansible can often be stuck until someone has a chance to port breaking changes between versions. Recently while on-boarding someone into a team, I went out and tried to find a way to do the install. Everything I tried didn’t work. It seems it was never the intention and so the packaging doesn’t really support it.
I’ve found a way though.
It’s a bit of a kludge, but it gets the job done.
Thanks to this issue/pr brew can install from a URL.
This means we can now find old formulas at github and just reference those. Let’s take terraform for example. At the time of writing it is currently at version 0.10.x. This is a breaking release from 0.9. The team I’m working in hasn’t had a chance to review and do the migration, so we’re stuck in 0.9 land, and specifically we are requiring 0.9.6.
You can browse the history of files at github. So let’s find the history of terraform formula.
Now you just find the version you want: 0.9.6, view the original file and then get the raw URL.
It’s now a simple case of calling brew with the full URL:
brew unlink terraform brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/e48725f6554e4034b91435aafaa4fa5a6d0cdc7d/Formula/terraform.rb
If you need to change versions you can use the switch command:
brew switch terraform 0.10.1
Not the cleanest of approaches, but it’s working for me! Good luck with your brew install versioning.