如何在自制程序中安装特定版本的公式?例如,postgresql-8.4.4而不是最新的9.0。
当前回答
我创建了一个工具来简化这个答案中规定的过程。
要查找a.b.c版本的软件包pkg,请运行:
$ brew-install-specific pkg@a.b.c
这将列出pkg-homebrew公式中提到给定版本的提交及其GitHub URL。
Matching versions:
1. pkg: update a.b.c bottle.
https://github.com/Homebrew/homebrew-core/commit/<COMMIT-SHA>
2. pkg: release a.b.c-beta
https://github.com/Homebrew/homebrew-core/commit/<COMMIT-SHA>
3. pkg a.b.c
https://github.com/Homebrew/homebrew-core/commit/<COMMIT-SHA>
Select index:
验证来自给定URL的提交,并输入所选提交的索引。
Select index: 2
Run:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/<COMMIT-SHA>/Formula/pkg.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>并升级。
基于@tschundee和@Debilski的更新1所描述的工作流,我自动化了该过程,并在此脚本中添加了清理。
下载它,将其放到您的路径中,然后brewv<formula_name><wanted_version>。对于特定OP,它将是:
cd path/to/downloaded/script/
./brewv postgresql 8.4.4
:)
这些都不适用于我的案例(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
按照@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
这里的其他答案很好,但如果您需要安装较旧版本的软件包并确保修改了软件包名称,则需要另一种方法。当使用脚本(在我的例子中是PHP构建脚本)时,这一点非常重要,这些脚本使用brew前缀package_name来确定要用于编译的目录。
如果您正在使用brew提取,则会在包名称的末尾添加一个版本,这将中断brew前缀查找。
以下是如何在保持原始软件包名称的同时安装较旧的软件包版本:
# uninstall the newer version of the package that you accidentally installed
brew uninstall --ignore-dependencies icu4c
# `extract` the version you'd like to install into a custom tap
brew tap-new $USER/local-tap
brew extract --version=68.2 icu4c $USER/local-tap
# jump into the new tap you created
cd $(brew --repository $USER/local-tap)/Formula
# rename the formula
mv icu4c@68.2.rb icu4c.rb
# change the name of the formula by removing "AT682" from the `class` definition
# the exact text you'll need to remove will be different
# depending on the version you extracted
nano icu4c.rb
# then, install this specific formula directly
brew install $(brew --repository $USER/local-tap)/Formula/icu4c.rb
我在这里写了更多。
推荐文章
- Homebrew:以新的formula@version格式列出可用版本
- 错误:无法在ARM处理器上的Homebrew中安装英特尔默认前缀(/usr/local)
- 酿造更新失败:未跟踪的工作树文件将被合并覆盖
- 在MacOS X上推荐用什么方式安装Node.js、nvm和npm ?
- 我如何安装imagemagick与自制?
- 我如何知道哪些自制配方是可升级的?
- "ERROR:root:code for hash md5 was not found"当使用任何hg mercurial命令时
- homebrew、macports或其他软件包安装工具的区别/用途是什么?
- Ruby Bundle Symbol not found: _SSLv2_client_method (LoadError)
- Virtualenvs中的破引用
- brew install XXX和brew cask install XXX有什么区别
- Brew安装docker不包括docker引擎?
- 我如何使用brew安装Python作为默认的Python?
- 如何用自制程序更新公式?
- 在安装Homebrew后,我得到' zsh:命令未找到:brew '