Homebrew install specific version of formula?

后端 未结 27 2135
渐次进展
渐次进展 2020-11-21 11:21

How do I install a specific version of a formula in homebrew? For example, postgresql-8.4.4 instead of the latest 9.0.

相关标签:
27条回答
  • 2020-11-21 12:23

    Along the lines of @halfcube's suggestion, this works really well:

    1. Find the library you're looking for at https://github.com/Homebrew/homebrew-core/tree/master/Formula
    2. Click it: https://github.com/Homebrew/homebrew-core/blob/master/Formula/postgresql.rb
    3. Click the "history" button to look at old commits: https://github.com/Homebrew/homebrew-core/commits/master/Formula/postgresql.rb
    4. Click the one you want: "postgresql: update version to 8.4.4", https://github.com/Homebrew/homebrew-core/blob/8cf29889111b44fd797c01db3cf406b0b14e858c/Formula/postgresql.rb
    5. Click the "raw" link: https://raw.githubusercontent.com/Homebrew/homebrew-core/8cf29889111b44fd797c01db3cf406b0b14e858c/Formula/postgresql.rb
    6. brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/8cf29889111b44fd797c01db3cf406b0b14e858c/Formula/postgresql.rb
    0 讨论(0)
  • 2020-11-21 12:24

    Update: 1/15/2015

    • Find the commit history of the desired software and version. e.g. I need to switch from docker version 1.4.1 to 1.3.3: https://github.com/Homebrew/homebrew-core/commits/master/Formula/docker.rb
    • View the file with this button: enter image description here
    • Click the Raw button: List item
    • Copy the URL (docker.rb url in this example) from address bar
    • brew install <url> (may have to brew unlink first, e.g. brew unlink docker)
    • brew switch docker 1.3.3
    • Switch back to docker 1.4.1 brew switch docker 1.4.1

    From this gist

    brew update
    brew versions FORMULA
    cd `brew --prefix`
    git checkout HASH Library/Formula/FORMULA.rb  # use output of "brew versions"
    brew install FORMULA
    brew switch FORMULA VERSION
    git checkout -- Library/Formula/FORMULA.rb    # reset formula
    
    ## Example: Using Subversion 1.6.17
    #
    # $ brew versions subversion
    # 1.7.3    git checkout f8bf2f3 /usr/local/Library/Formula/subversion.rb
    # 1.7.2    git checkout d89bf83 /usr/local/Library/Formula/subversion.rb
    # 1.6.17   git checkout 6e2d550 /usr/local/Library/Formula/subversion.rb
    # 1.6.16   git checkout 83ed494 /usr/local/Library/Formula/subversion.rb
    # 1.6.15   git checkout 809a18a /usr/local/Library/Formula/subversion.rb
    # 1.6.13   git checkout 7871a99 /usr/local/Library/Formula/subversion.rb
    # 1.6.12   git checkout c99b3ac /usr/local/Library/Formula/subversion.rb
    # 1.6.6    git checkout 8774131 /usr/local/Library/Formula/subversion.rb
    # 1.6.5    git checkout a82e823 /usr/local/Library/Formula/subversion.rb
    # 1.6.3    git checkout 6b6d369 /usr/local/Library/Formula/subversion.rb
    # $ cd `brew --prefix`
    # $ git checkout 6e2d550 /usr/local/Library/Formula/subversion.rb
    # $ brew install subversion
    # $ brew switch subversion 1.6.17
    # $ git checkout -- Library/Formula/subversion.rb
    
    0 讨论(0)
  • 2020-11-21 12:24

    None of these really worked for my case (Python), so I'll add my 2 cents:

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

    Output looks like this:

    commit 9ff2d8ca791ed1bd149fb8be063db0ed6a67a6de
    Author: Dominyk Tiller <dominyktiller@gmail.com>
    Date:   Thu Jun 30 17:42:18 2016 +0100
    
        python: clarify pour_bottle reason
    
    commit cb3b29b824a264895434214e191d0d7ef4d51c85
    Author: BrewTestBot <brew-test-bot@googlegroups.com>
    Date:   Wed Jun 29 14:18:40 2016 +0100
    
        python: update 2.7.12 bottle.
    
    commit 45bb1e220341894bbb7de6fd3f6df20987dc14f0
    Author: Rakesh <rakkesh@users.noreply.github.com>
    Date:   Wed Jun 29 10:02:26 2016 +0530
    
        python 2.7.12
    
        Closes #2452.
    
        Signed-off-by: Tim D. Smith <git@tim-smith.us>
    
    commit cf5da0547cd261f79d69e7ff62fdfbd2c2d646e9
    Author: BrewTestBot <brew-test-bot@googlegroups.com>
    Date:   Fri Jun 17 20:14:36 2016 +0100
    
        python: update 2.7.11 bottle.
    
    ...
    

    I want version 2.7.11 so my hash is cf5da0547cd261f79d69e7ff62fdfbd2c2d646e9 (or cf5da05 for short). Next, I check out that version and install the formula python:

    git checkout cf5da05
    brew install python
    

    Finally, clean up:

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