How to install older formula using Brew?

后端 未结 3 449
攒了一身酷
攒了一身酷 2020-12-12 22:31

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

相关标签:
3条回答
  • 2020-12-12 23:12

    Homebrew doesn't support installing formulas from git history, although it's possible. There are no python* formulas in the homebrew-versions tap because I think they would be a lot of work to maintain and don't provide the best possible user experience. pyenv is a great tool that solves a lot of the problems associated with keeping multiple pythons around. There's also a user-maintained tap with older Python versions; you could contribute a 2.7.9 formula there.

    0 讨论(0)
  • 2020-12-12 23:22

    If you want install a specific python version using brew (Home brew).

    Example: I am trying to install python 3.7 and current python at this time is python 3.8

    brew install python@3.7 -- This will make me install python 3.7

    brew install python -- This will make me install python 3.8 which is current version of python while writing this comment.

    0 讨论(0)
  • 2020-12-12 23:26

    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.

    0 讨论(0)
提交回复
热议问题