Photo by Evan Dvorkin on Unsplash

How to Install an Older Brew Package

Switch to a specific Brew Formula version from the past

The simplicity of the App Store was a genius move from Apple to ease software delivery to its end-users (and make a ton of money in the process). However, not all apps and utilities make it to the App Store. For all those, not App Store-privileged software, you need to either build them from source or install them via a third-party package manager. Here’s where MacPorts, Fink, and Homebrew come to fill the void:

Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system and Linux. The name is intended to suggest the idea of building software on the Mac depending on the user’s taste.

Installing the latest package: Easy

Installing with brew can’t be made any simpler. Search the package you need, type brew install <package-name> , and that’s all. A few seconds later, Homebrew will pick the correct version of the package matching your macOS and make it available to your CLI.

Homebrew will make the newly installed package accessible in your default path and it’s clever enough to not do so when what you have just installed clashes with an Apple-provided package.

Installing an older package: Not so easy

Unfortunately, Homebrew doesn’t provide an easy, out-of-the-box way to install an older version of a package. If for any reason you find yourself in need of an older version, you have to perform some preparatory manual steps first.

Installing a version you had in the past

If the older version you’re looking to switch back to has been installed by Homebrew in the past, you’re lucky. You can see which versions are locally available by issuing:

brew info <package-name>

Here’s an example for Ant (to not sidetrack this post, let’s just say there are better, modern alternatives these days):

LIsting locally available Homebrew packages

Pick one of the existing local version and switch to it via:

brew switch <package-name> <version>

Switching back to an older version previously installed

Installing an older version you never had installed before

This is where things get a little more involving. Since Homebrew doesn’t provide a command to arbitrarily select a version to install, you have to manually find the version you need in Homebrew’s GitHub repository, copy the URL to it and pass it as an argument for manual installation.

Let’s see how to do all this.

Go to https://github.com/Homebrew/homebrew-core/find/master and type the name of the package you are looking for (I use ant package as an example):

Searching HomeBrew packages

2. Click on the matching package Formula ending in .rb and then view its previous version by clicking on the History button:

View the previous versions of a Homebrew formula

3. Find the version you want and click on the commit ID:

Find the version and see the respective commit

4. Click the ellipsis button “…”, choose “View file”, and then “Raw”:

Viewing the full source of the file

Getting the URL to the .rb file for the version you need

5. Copy the (raw) URL you have in your browser into your clipboard.

6. You can, finally, install the version you have found above by executing: