How to install an older homebrew package


Did you know it’s possible to install an older version of a homebrew package or formula?

Previously, you would do this by installing an older formula URL:

brew install <FORMULA_URL>

However, this no longer works:

Error: Calling Installation of <FORMULA> from a GitHub commit URL is disabled! Use 'brew extract <FORMULA>' to stable tap on GitHub instead.

Now, you need to replace the core or cask formula before installing:

# copy formula code
pbpaste > $(find $(brew --repository) -name <FORMULA>.rb)
brew install <FORMULA>

Example

The following steps outline how to install composer version 1.10.15.

Prerequisites

Uninstall composer:

brew uninstall composer

Update brew:

brew update

Find the Formula

Find the formula in homebrew-core or homebrew-cask:

Find formula

The formula filename should be composer.rb.

Open the file and click History:

Click History

Browse through the history and find the commit you want:

Browse commit history

Go to the commit, click the ellipsis next to the file, and click View file:

View file

Click Raw to open the raw file:

Click Raw

Replace the Formula

Select and copy the raw formula:

Copy code

Open the local formula on your machine:

find $(brew --repository) -name composer.rb

Paste the copied formula so it replaces the local formula:

pbpaste > $(find $(brew --repository) -name composer.rb)

Install the formula:

brew install composer

Once that’s done, undo the changes to the formula:

cd $(find $(brew --repository) -name composer.rb -exec dirname {} \;)
git checkout .

Pin the formula to prevent accidental upgrade:

brew pin composer

Resources

Homebrew documentation:



If you enjoyed this post, please consider supporting this site!