如何在自制程序中安装特定版本的公式?例如,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

其他回答

按照@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

我刚刚将一个较旧版本的弹性搜索复制到/usr/local/Cellar/lelasticsearch目录中。

$ mkdir /usr/local/Cellar/elasticsearch/5.4.3/bin
$ cp elasticsearch /usr/local/Cellar/elasticsearch/5.4.3/bin
$ brew switch elasticsearch 5.4.3

就是这样。也许它对任何人都有用。

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

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

这些都不适用于我的案例(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

⚠ 这个答案在2020年12月后不再有效:在HomeBrew 2.7.0中禁用了brew开关(2.6.0中已弃用)


对于2.7之前的Homebrew版本:

现在有一种更简单的方法来安装以前安装的公式的旧版本。简单使用

brew switch [formula] [version]

例如,我定期在Node.js 0.4.12和0.6.5之间切换:

brew switch node 0.4.12
brew switch node 0.6.5

由于brew开关只是更改符号链接,所以速度非常快。请参阅外部命令下Homebrew Wiki的更多文档。