如何使用Brew安装较旧的配方? [英] How to install older formula using Brew?

查看:102
本文介绍了如何使用Brew安装较旧的配方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装Python 2.7.9而不是最新的2.7.10的情况下,以前我可以简单地使用brew versions python并通过在brew中提交SHA来查看所有Python公式版本,然后将它们检出到安装特定版本.这是brew versions python输出的示例:

$ brew versions python
Warning: brew-versions is unsupported and will be removed soon.
You should use the homebrew-versions tap instead:
  https://github.com/Homebrew/homebrew-versions
2.7.9    git checkout 667284f /usr/local/Library/Formula/python.rb
2.7.8    git checkout f26ca5c /usr/local/Library/Formula/python.rb
2.7.7    git checkout d48206e /usr/local/Library/Formula/python.rb
2.7.6    git checkout 3c64184 /usr/local/Library/Formula/python.rb
2.7.5    git checkout a04b443 /usr/local/Library/Formula/python.rb
2.7.3    git checkout 865f763 /usr/local/Library/Formula/python.rb
2.7.4    git checkout 280581d /usr/local/Library/Formula/python.rb
2.7.2    git checkout 97c6869 /usr/local/Library/Formula/python.rb
2.7.1    git checkout 83ed494 /usr/local/Library/Formula/python.rb
2.7      git checkout 1bf3552 /usr/local/Library/Formula/python.rb
2.6.5    git checkout acd49f7 /usr/local/Library/Formula/python.rb
2.6.4    git checkout 843bff9 /usr/local/Library/Formula/python.rb
2.6.3    git checkout 5c6cc64 /usr/local/Library/Formula/python.rb

但是brew的最新版本已经删除了对versions的支持,而且我不明白如何使用 https://github.com/Homebrew/homebrew-versions .您实际上如何安装Python 2.7.9而不是较新的2.7.10?

我想知道如何使用homebrew-versions而不是更简单的方法brew versions.

使用brew versions,我可以轻松地查看该特定公式的所有版本(请查看brew versions python吐出的上述Python版本).在 doc 中,没有明确的方法可以实现与brew versions python相同的结果.

解决方案

homebrew-versions曾经是最简单的方法,但是homebrew-versions已被弃用,并且在当前版本的homebrew中不再可用. /p>

要查找易于使用的版本,请使用以下命令:

brew search python

列出所有可用的python软件包,这些软件包将显示类似python@2的旧版本,然后您可以使用以下命令进行安装:

brew install python@2

一些替代方法

切换到以前的版本

如果您已经安装了较旧版本的公式,但尚未删除它,则可以使用brew命令简单地切换符号链接以引用它.

brew switch python 2.7.9

此命令会将您切换到2.7.9版

brew switch python 2.7.10

这会将您切换回2.7.10版

Formula GitHub历史记录

如果您的系统上仍然没有较旧的版本,您可以尝试另一种方法,但是它比较困难,而且几乎肯定不受Homebrew的支持,因此,如果您遇到问题,则可能无法依靠它们帮助.

https://github.com/Homebrew/homebrew-core/commits/master/Formul/<formula>.rb应该带您进入该公式的提交历史记录.对于安装python 2.7.9的示例,您将执行以下操作:

  1. 转到https://github.com/Homebrew/homebrew-core/commits/master/Formula/python.rb
  2. 使用提交摘要"python 2.7.10"查找条目
  3. 查找并复制其下方条目的提交哈希(在本示例中为1681e19)
  4. 在终端中输入git checkout 1681e19 /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python.rb

从这一点开始,您将执行通常使用旧版本方法安装旧版本python的所有操作.这似乎是旧方法所做的全部.

Using the case of installing Python 2.7.9 instead of the latest 2.7.10, previously I could simply use brew versions python and see all of the versions of Python formulae by their commit SHA in brew, and then check them out to install a specific version. This is an example of brew versions python output:

$ brew versions python
Warning: brew-versions is unsupported and will be removed soon.
You should use the homebrew-versions tap instead:
  https://github.com/Homebrew/homebrew-versions
2.7.9    git checkout 667284f /usr/local/Library/Formula/python.rb
2.7.8    git checkout f26ca5c /usr/local/Library/Formula/python.rb
2.7.7    git checkout d48206e /usr/local/Library/Formula/python.rb
2.7.6    git checkout 3c64184 /usr/local/Library/Formula/python.rb
2.7.5    git checkout a04b443 /usr/local/Library/Formula/python.rb
2.7.3    git checkout 865f763 /usr/local/Library/Formula/python.rb
2.7.4    git checkout 280581d /usr/local/Library/Formula/python.rb
2.7.2    git checkout 97c6869 /usr/local/Library/Formula/python.rb
2.7.1    git checkout 83ed494 /usr/local/Library/Formula/python.rb
2.7      git checkout 1bf3552 /usr/local/Library/Formula/python.rb
2.6.5    git checkout acd49f7 /usr/local/Library/Formula/python.rb
2.6.4    git checkout 843bff9 /usr/local/Library/Formula/python.rb
2.6.3    git checkout 5c6cc64 /usr/local/Library/Formula/python.rb

But the latest version of brew has already removed versions support, and I don't understand how to install a previous Python using https://github.com/Homebrew/homebrew-versions. How do you actually install Python 2.7.9 instead of the newer 2.7.10?

I would like to know how to use homebrew-versions instead of the more trivial way brew versions.

With brew versions I could easily see all versions from that specific formulae (have a look at the above Python versions spit out by brew versions python). From the doc, there is no clear way to achieve the same result as brew versions python does.

解决方案

homebrew-versions used to be the easiest way to do this, but homebrew-versions has been deprecated and is no longer available in the current version of homebrew.

To find what versions are readily available, use the following command:

brew search python

to list out all of the available python packages which would display old versions like python@2 and then you could install them by using:

brew install python@2

Some Alternative Approaches

Switching To Previous Version

If you have already installed the older version of the formula and have not removed it you can simply switch the symlinks to reference it using a brew command.

brew switch python 2.7.9

This command would switch you to version 2.7.9

brew switch python 2.7.10

This would switch you back to version 2.7.10

Formula GitHub History

If you do not still have the older version available on your system there is another method you could try but it is more difficult and almost certainly unsupported by Homebrew so if you end up with issues you may not be able to rely on their help.

https://github.com/Homebrew/homebrew-core/commits/master/Formul/<formula>.rb should take you to the commit history of that formula. For your example of installing python 2.7.9 you would do the following:

  1. Go to https://github.com/Homebrew/homebrew-core/commits/master/Formula/python.rb
  2. Look for the entry with a commit summary of "python 2.7.10"
  3. Find and copy the commit hash of the entry below it (1681e19 in this example)
  4. Input git checkout 1681e19 /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python.rb into the terminal

From this point you would do whatever you would normally do to install the older version of python with the old versions method. This appears to be all the old method was doing.

这篇关于如何使用Brew安装较旧的配方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆