DevOps

Install a Specific Homebrew Formula Version (Postgres)

Install a specific Homebrew formula (e.g., postgresql@8.4.4) via versioned @-formulae or brew extract into a tap. Commands, linking, pinning and troubleshooting.

1 answer 5 views

How do I install a specific version of a formula in Homebrew? For example, how can I install postgresql-8.4.4 instead of the latest version 9.0?

You can install a homebrew specific version either from an existing versioned @-formula (if one exists) or — more generally — by using brew extract to copy a historical formula into a personal tap and installing that copy. For example, extract the old postgresql formula and then run brew install <your-tap>/postgresql@8.4.4; expect to build from source and possibly patch dependencies on modern macOS. Want the short route? Check for postgresql@… first; otherwise use brew extract.


Contents


Overview

Homebrew doesn’t provide a single built‑in command to “install any historical version” of a formula out of the box. Some formulae ship as versioned formulae (the name@version pattern) and can be installed directly; when they aren’t available, the supported approach is to extract the older formula from Homebrew’s git history into a custom tap and install from there. The official Homebrew docs describe recovering old formulae with brew extract — that’s the safest, repeatable path to get a specific historic formula onto your machine (Formulae Versions).

Want to skip the long explanation? Try brew search postgresql@ first. If nothing appropriate shows up, follow the extract workflow below.


Versioned @-formulae: quick check

Before digging into history, see whether Homebrew already supplies the version you need as a versioned formula.

  • Search available versioned formulae:
bash
brew update
brew search postgresql@
  • If you find the exact version (for example postgresql@9.6), install and (optionally) pin it:
bash
brew install postgresql@9.6
brew pin postgresql@9.6 # prevents automatic upgrades
  • Linking: if another Postgres is already linked, unlink it first and then link the one you want:
bash
brew unlink postgresql
brew link --force --overwrite postgresql@9.6

The Homebrew Tips and Tricks docs mention the @ naming convention and that brew extract is the fallback when a named version doesn’t exist (Tips and Tricks). If a versioned formula exists, that’s often the easiest and cleanest option.


Install a specific version with brew extract

When a versioned formula isn’t available, brew extract is the recommended method. In short: you extract the old formula revision into a new personal tap, then install that extracted formula.

Why use brew extract? It pulls the exact historical formula from Homebrew’s git history, writes a new formula into your tap with the proper name, and keeps Homebrew’s checks and paths tidy. Community guides show the same sequence and explain why extracting beats raw installs from arbitrary URLs (example walkthroughs: Installing Old Homebrew Formula Versions and a practical rollback example at Eric Bariaux).

Canonical steps (explainers follow in the example section):

bash
# make sure you have the core history locally
brew update
brew tap homebrew/core --force

# create your personal tap (replace USER with your GitHub user or short name)
brew tap-new $USER/old-formulae

# extract the exact version into that tap
brew extract --version=8.4.4 postgresql $USER/old-formulae

# install the extracted formula
brew install $USER/old-formulae/postgresql@8.4.4

# optional: prevent accidental upgrades
brew pin $USER/old-formulae/postgresql@8.4.4

Notes while extracting:

  • If brew extract can’t find the version, it means that exact version string or commit isn’t present in homebrew-core history in the expected place; see “Install from a commit” below for alternatives.
  • brew extract produces a proper formula inside your tap; from then on Homebrew handles installation normally.

Install from a commit or raw formula (less recommended)

If brew extract fails or you prefer to install a specific commit directly, you can fetch the historical formula file from the Homebrew GitHub repo and install it. This method works, but it’s less robust and may run into checksum/security blockers — which is why Homebrew docs and many guides recommend brew extract first.

Workflow outline:

  1. Find the commit SHA on GitHub where the formula was the desired version (search the Homebrew/homebrew-core repo history for Formula/postgresql.rb and the version string).
  2. Install from the raw file (example form):
bash
brew install "https://raw.githubusercontent.com/Homebrew/homebrew-core/<COMMIT_SHA>/Formula/postgresql.rb"
# or
curl -L -o postgresql.rb "https://raw.githubusercontent.com/Homebrew/homebrew-core/<COMMIT_SHA>/Formula/postgresql.rb"
brew install ./postgresql.rb

Community writeups show this approach in practice but warn about checksum mismatches and bottles not being available; you’ll often build from source. See a practical guide that describes both approaches and caveats: How to install specific older Homebrew package versions.


Step-by-step: install postgresql@8.4.4

Here’s a tested, repeatable sequence using brew extract. Replace $USER with your short username or GitHub user (this becomes the tap name).

  1. Update and check prerequisites:
bash
brew update
brew doctor
xcode-select --install # if you don't have the command-line tools
  1. Ensure homebrew/core history is available locally:
bash
brew tap homebrew/core --force

(For some Homebrew states you can also use brew tap --force homebrew/core — either form has been used in community guides.)

  1. Create a personal tap to hold extracted formulae:
bash
brew tap-new $USER/old-formulae
# Example result: your new tap is $USER/old-formulae
  1. Extract the historic postgresql formula into your tap:
bash
brew extract --version=8.4.4 postgresql $USER/old-formulae
  • If this succeeds you’ll see a new formula in your tap named something like postgresql@8.4.4.rb.
  • If it errors with “unable to find” then the exact version token isn’t detected in the core git history; try searching the repo for the right version string or use the commit/raw-file method (above).
  1. Install the extracted formula:
bash
brew install $USER/old-formulae/postgresql@8.4.4
  • This will probably build from source (no bottle for such an old version). Expect longer compile time and possible failures.
  1. Manage links and services:
bash
brew services stop postgresql # stop any running postgres
brew unlink postgresql # unlink newer installed versions
brew link --force --overwrite postgresql@8.4.4
brew services start postgresql@8.4.4
  • If linking fails because the formula is keg-only, follow the message Homebrew prints (it’ll tell you the path to binaries).
  1. Pin the installed version to avoid upgrades:
bash
brew pin postgresql@8.4.4
  1. If the build fails:
  • Try building from source explicitly: brew install --build-from-source $USER/old-formulae/postgresql@8.4.4.
  • Inspect and edit the formula: brew edit $USER/old-formulae/postgresql@8.4.4 — you can change dependency names, flags, or checksums to match what’s available today.
  • If the formula depends on ancient libraries (e.g., OpenSSL 0.9.x), you may need an older OS or a container that mirrors the era the formula was written for.

For a live example and command-by-command explanation, see this community walkthrough that used postgresql 8.4.4 as an example: Installing Old Homebrew Formula Versions.


Troubleshooting & tips

  • Q: brew extract can’t find the version.
    A: Search the core repo history directly:
bash
cd "$(brew --repo homebrew/core)"
git log -- Formula/postgresql.rb --pretty=oneline | grep 8.4.4

Or search on GitHub for the formula and the version string. If you find the commit SHA, install from the raw file (see “Install from a commit”).

  • Q: Build fails on modern macOS.
    A: Older code may rely on headers, flags or system libraries that no longer exist. Consider:

  • Editing the extracted formula to update dependencies or flags (brew edit).

  • Using an older macOS VM or Docker container that matches the era.

  • Installing required legacy libraries if Homebrew still supplies them (e.g., older OpenSSL formulae), or backporting patches.

  • Q: brew install <raw-url> is blocked or gives checksum errors.
    A: Homebrew may refuse unverified bottles. Use brew extract (recommended) or manually download and brew install ./formula.rb after inspecting the file.

  • Q: How do I keep multiple Postgres versions?
    A: You can keep multiple kegs installed; don’t link them at the same time. Use explicit paths to binaries (e.g., /usr/local/opt/postgresql@8.4.4/bin/psql), or manage services with brew services.

  • Q: Is this supported for casks?
    A: No. brew extract targets formulae (packages). Casks follow a different workflow.

  • Pro tip: always run brew info <formula> after install to see caveats and paths. For deeper help, community Q&A threads show real-world fixes: see the Stack Overflow discussions on installing specific Homebrew versions (example 1, example 2).


Sources


Conclusion

To install a homebrew specific version you should first check for a versioned @ formula (quickest), and otherwise use brew extract to pull the historic formula into a personal tap and install it. For your example, extracting postgresql@8.4.4 into a local tap and installing that formula is the recommended, repeatable method; just be ready to build from source and to fix dependency or macOS-compatibility issues.

Authors
Verified by moderation
Moderation
Install a Specific Homebrew Formula Version (Postgres)