小能豆

Homebrew install specific version of formula?

javascript

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


阅读 224

收藏
2023-12-27

共1个答案

小能豆

As of my knowledge cutoff in January 2022, Homebrew primarily supports installing the latest versions of formulas. However, if you specifically need an older version of a formula, you can use the brew tap command to tap into a repository that contains the historical versions.

Here are the steps:

  1. Tap the Versions Repository:

Homebrew provides a “homebrew-versions” repository where older versions of formulas are kept. Tap this repository using the following command:

brew tap homebrew/homebrew-versions

This will add the “homebrew/versions” tap to your Homebrew.

  1. Install the Specific Version:

After tapping the repository, you can use the brew install command to install the specific version of the formula you need. For example:

brew install postgresql@8.4

This installs PostgreSQL version 8.4. Keep in mind that the formula name might slightly differ for some packages.

  1. Link the Formula:

After installation, you may need to link the formula to make it usable. Follow any instructions provided by Homebrew after the installation command. For example:

brew link postgresql@8.4 --force

The --force flag might be required if there are conflicts with other installed versions.

Please note that the availability of older versions depends on whether they are maintained in the “homebrew-versions” tap. If the tap doesn’t have the version you need, you might need to explore other options such as compiling from source or using version managers like asdf or pyenv, which can handle multiple versions of various tools.

Keep in mind that Homebrew and its ecosystem may have evolved since my last training data in January 2022, so it’s always a good idea to check the latest Homebrew documentation or community discussions for the most up-to-date information.

2023-12-27