Homebrew install specific version of formula?

后端 未结 27 2112
渐次进展
渐次进展 2020-11-21 11:21

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

27条回答
  •  梦如初夏
    2020-11-21 12:02

    You can use the strategy of identifying the formula and a particular commit in the history of the formula that matches the version of the package you'd like to install.

    1. Go to https://github.com/Homebrew/homebrew-core

    2. Press t on your keyboard to activate the file finder.

    3. Identify a formula that looks most relevant, perhaps: Formula/mysql.rb, bringing you to a forumla file location: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb.

    4. Look at the revision history by clicking on the History button, which is located at https://github.com/Homebrew/homebrew-core/commits/master/Formula/mysql.rb. If you're interested in MySQL 5.7.10, you might want to click the latest revision prior to 5.7.11, which navigates to a GitHub commit:

      https://github.com/Homebrew/homebrew-core/commit/c77882756a832ac1d87e7396c114158e5619016c#Formula/mysql.rb

    NOTE: You may have to view the commit history in your console per GitHub's suggestion if the commit history does not load in your browser. Replace the commit SHA above in the URL if you're interested in seeing that commit on GitHub. Alternatively, skip to step 7, below.

    1. Click the "View" button to view the source for the mysql.rb file after the commit was applied.

    2. Then click the "Raw" button to view the raw source.

    3. Copy the URL. Alternatively, build the URL yourself with the mysql.rb file name to identify your formula and the particular version of that formula (identified by the commmit SHA in the URL below).

      https://raw.githubusercontent.com/Homebrew/homebrew-core/c77882756a832ac1d87e7396c114158e5619016c/Formula/mysql.rb

    4. Install it with $ brew install [URL from step 7]

      $ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/c77882756a832ac1d87e7396c114158e5619016c/Formula/mysql.rb
      

    NOTE: This answer was updated to account for the removal of the braumeister.org website. The same principle applies, braumeister had simply provided a beginner-friendly way to navigate formula versions.

提交回复
热议问题