Homebrew is a popular package manager for macOS, providing an easy way to install and manage software. While Homebrew itself is constantly updated, sometimes you may want to install a specific version of a formula (i.e., package) that is not the latest. In this article, we will cover how to install a specific commit of a Homebrew formula.
Prerequisites
Before we begin, ensure you have Homebrew installed on your system. If not, follow the instructions on the official Homebrew website to install it.
Install a Specific Commit
To install a specific commit of a Homebrew formula, you'll need to use the git command to clone the formula's repository and checkout the desired commit. Here's a step-by-step guide:
- Find the commit hash you want to install. You can use the Homebrew core search or the commit history to find the desired commit.
- Open a terminal window and navigate to the directory where you want to install the formula.
-
Clone the formula's repository using the following command, replacing
FORMULA_NAMEwith the name of the formula andCOMMIT_HASHwith the desired commit hash: -
Install the formula using Homebrew's
installcommand:
$ git clone https://github.com/Homebrew/homebrew-core/formula/FORMULA_NAME.git Formula-FORMULA_NAME-COMMIT_HASH
$ cd Formula-FORMULA_NAME-COMMIT_HASH
$ brew install .
Example
Let's say you want to install version 1.14.2 of the mysql formula from commit 6f36887. Here's what the command would look like:
$ git clone https://github.com/Homebrew/homebrew-core/formula/mysql.git mysql-6f36887
$ cd mysql-6f36887
$ brew install .
Installing a specific commit of a Homebrew formula allows you to use an older version of the software. By following the steps outlined above, you can easily install a desired commit and manage your software environment.