Skip to main content
Engineering Notes · July 2018

Installing a Specific Version of a Homebrew Formula

Portrait of Komang Artha Yasa — technology leader, two decades building digital platforms across marketplaces, retail, logistics, fintech, and banking.

This guide is for those who need to install a specific version of aHomebrew formula — usually an older one. Go to the Homebrew core dir:

cd "$(brew --repo homebrew/core)"

We need a full clone to view the entire commit log; by default it’s a shallow clone:

git -C "$(brew --repo homebrew/core)" fetch --unshallow

Find the version in the formula’s commit log. Mine is Solr 6.6.x:

git log Formula/solr.rb

The result looks like this:

commit 39bcac0377155f97b0edd28bea731dd1b14b9c99
Author: Ryan Baumann <[email protected]>
Date:   Thu Jun 29 06:16:38 2017 -0400

    solr 6.6.0 (#15004)

Create a new branch pinned to that commit:

git checkout -b solr-660 39bcac0377155f97b0edd28bea731dd1b14b9c99

Install with auto-update turned off, so Homebrew doesn’t fast-forward you off the pinned commit:

HOMEBREW_NO_AUTO_UPDATE=1 brew install solr

All good? Clean up:

git checkout master
git branch -d solr-660

A Snag

While installing this version I ran into:

Error: Failed to install plist file
Error: undefined method `undent' for #<String:0x00007f9f4e97df48>

It’s a known open issue with an easy workaround — manually remove .undent from solr.rb before installing:

/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/solr.rb

Done. :-)