I’m an avid user of Homebrew on macOS.
Doing an updates rightly updates all software installed through Homebrew to their latest version as expected. But, sometimes, you might want to install the previous version of a program. Here is the correct way to do it courtesy of variar on Stack Overflow:
TAP=... # <org>/<repo>, for example "my-org/homebrew-old" MODULE=... # name of module you want to install, e.g. "hugo" VERS=... # version of $MODULE you want to install, e.g., "0.80.0" brew tap-new $TAP brew extract --version $VERS $MODULE $TAP brew install $TAP/$MODULE@$VERS
An example without using the shell variables is as follows:
brew tap-new avinash/homebrew-old brew extract --version 2.51.3 unison avinash/homebrew-old brew install avinash/homebrew-old/unison@2.51.3
The first command creates a new tap called avinash/homebrew-old and this needs to be done only once.
This will install a previous version of unison, version 2.51.3. Incidentally, to obtain the list of versions of a specific Homebrew program (called a formula), you can use this excellent search feature of Github.
Teejay says
Hey Avinash, tahnk you for the solution but I have an issue, how do I install with a previous version of Ocaml, in my case version 4.09.1.
Avinash Meetoo says
Hi Teejay,
I am not too sure that you can install 4.09.1 according to the history of the forumla on Github (see https://github.com/Homebrew/homebrew-core/commits/d4c76ef0df689fcbe50ba522c377de43335c34bc/Formula/ocaml.rb)
It looks like 4.09.0 and 4.10.0 are definite possibilities if you follow the above procedure.
Hope this helps.