如何在自制程序中安装特定版本的公式?例如,postgresql-8.4.4而不是最新的9.0。


当前回答

如果无法使用brew search<formula>找到您的版本,您也可以尝试查看公式的提交日志,以找到所需的版本:

下面是通过brew安装旧版本nginx的示例:

ngxnx公式提交日志参见nginx:更新1.6.3瓶装eba75b9a1a474b9fc4df30bd0a32637fa31ec049

从那里,我们可以使用sha和原始git url安装1.6.3:

brew安装https://raw.githubusercontent.com/Homebrew/homebrew/eba75b9a1a474b9fc4df30bd0a32637fa31ec049/Library/Formula/nginx.rb

其他回答

其他答案都没有充分涵盖2022年的这一问题,因此我添加了以下说明,这些说明改编自Homebrew维护人员对安装特定酒桶版本的类似问题的回答:https://stackoverflow.com/a/62765875/6310633

卸载公式

brew uninstall <formula>

切换到自制核心回购的克隆,并重置为包含所需版本的提交。

cd "$(brew --prefix)/Library/Taps/homebrew/homebrew-core/Formula"
git log <formula>.rb # examine recent commits for <formula>
git reset --hard <commit-sha> # reset clone to last known-good commit for <formula>

为您的版本签出一个新的分支,这样brew不会在每次命令后自动刷新master,安装您的公式并锁定它。

git checkout -b <formula>-downgrade-<version>
brew install <formula>
brew pin <formula>

清理

git checkout master
brew update

当您准备好升级公式时,您可以像往常一样酿造unpin<formula>并升级。

我发现了比其他复杂解决方案更好的替代方案。

brew install https://raw.github.com/Homebrew/homebrew-versions/master/postgresql8.rb

这将下载并安装PostgreSQL 8.4.8


我通过开始遵循搜索回购和回购中的注释的步骤找到了这个解决方案。

经过一番研究发现,有人收集了一些罕见的配方奶粉。


如果您正在查找MySQL 5.1.x,请尝试一下。

brew install https://raw.github.com/Homebrew/homebrew-versions/master/mysql51.rb

按照@halfcube的建议,这非常有效:

查找您要查找的库https://github.com/Homebrew/homebrew-core/tree/master/Formula单击它:https://github.com/Homebrew/homebrew-core/blob/master/Formula/postgresql.rb单击“历史记录”按钮查看旧提交:https://github.com/Homebrew/homebrew-core/commits/master/Formula/postgresql.rb单击所需的选项:“postgresql:update version to 8.4.4”,https://github.com/Homebrew/homebrew-core/blob/8cf29889111b44fd797c01db3cf406b0b14e858c/Formula/postgresql.rb单击“原始”链接:https://raw.githubusercontent.com/Homebrew/homebrew-core/8cf29889111b44fd797c01db3cf406b0b14e858c/Formula/postgresql.rbbrew安装https://raw.githubusercontent.com/Homebrew/homebrew-core/8cf29889111b44fd797c01db3cf406b0b14e858c/Formula/postgresql.rb

这些都不适用于我的案例(Python),所以我将添加我的2美分:

cd `brew --prefix`
git log Library/Formula/python.rb

输出如下所示:

提交文件作者:Dominik Tiller<dominyktiller@gmail.com>日期:2016年6月30日星期四17:42:18+0100python:澄清pour-bottle原因提交cb3b29b824a264895434214e191d0d7ef4d51c85作者:BrewTestBot<brew-test-bot@googlegroups.com>日期:2016年6月29日星期三14:18:40+0100python:更新2.7.12瓶。提交45bb1e20234184bbb7d6fd3f6df20987dc14f0作者:Rakesh<rakkesh@users.noreply.github.com>日期:2016年6月29日星期三10:02:26+0530python 2.7.12关闭#2452。签字人:Tim D.Smith<git@tim-smith.us>提交cf5da0547cd261f79d69e7ff62fdfbd2c2d646e9作者:BrewTestBot<brew-test-bot@googlegroups.com>日期:2016年6月17日星期五20:14:36+0100python:更新2.7.11瓶子。...

我想要2.7.11版本,所以我的哈希是cf5da0547cd261f79d69e7ff62fdfbd2c2d646e9(简称cf5da05)。接下来,我检查该版本并安装公式python:

git checkout cf5da05
brew install python

最后,清理:

git checkout master

编辑:2021,由于github安装被弃用,这个答案不再起作用。(感谢蒂姆·史密斯的更新)。

安装旧的酿造包版本(Flyway 4.2.0示例)

查找本地自制程序gitdir或本地克隆homebrew/homebrew内核

cd/usr/local/Homebrew/Library/Taps/Homebrew/Homebrew内核/

OR

git克隆git@github.com:Homebrew/Homebrew-core.git

列出所有可用版本

git log master--Formula/flyway.rb

复制所需版本的提交ID并直接安装

brew安装https://raw.githubusercontent.com/Homebrew/homebrew-core/793abfa325531415184e1549836c982b39e89299/Formula/flyway.rb