Homebrew install specific version of formula?

后端 未结 27 2130
渐次进展
渐次进展 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 11:57

    Currently the old ways of installing specific formula versions have been deprecated. So it seems like we have to use brew edit [formula]. E.g. say we want to install an the 62.1 version of icu4c (needed e.g. for postgresql 10.5). Then you'd have to

    > brew edit icu4c
    # drops you to editor
    

    Here you'd have to alter the url, version and sha256 (perhaps also mirror) to the corresponding 62.1 strings.

    url "https://ssl.icu-project.org/files/icu4c/62.1/icu4c-62_1-src.tgz"
    mirror "https://github.com/unicode-org/icu/releases/download/release-62-1/icu4c-62_1-src.tgz"
    version "62.1"
    sha256 "3dd9868d666350dda66a6e305eecde9d479fb70b30d5b55d78a1deffb97d5aa3"
    

    then run brew reinstall icu4c to finally download the 62.1 version.

    0 讨论(0)
  • 2020-11-21 11:59

    I just copied an older release of elasticsearch into the /usr/local/Cellar/elasticsearch directory.

    $ 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
    

    That's it. Maybe it's useful for anyone.

    0 讨论(0)
  • 2020-11-21 11:59

    I created a tool to ease the process prescribed in this answer.

    To find a package pkg with version a.b.c, run:

    $ brew-install-specific pkg@a.b.c
    

    This will list commits on the pkg homebrew formula that mention the given version along with their GitHub urls.

    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: 
    

    Verify the commit from the given URL, and enter the index of the selected commit.

    Select index: 2
    Run:
      brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/<COMMIT-SHA>/Formula/pkg.rb
    

    Copy and run the given command to install.

    0 讨论(0)
  • 2020-11-21 12:02

    You can use the strategy of identifying the formula and a particular commit in the history of the formula that matches the version of the package you'd like to install.

    1. Go to https://github.com/Homebrew/homebrew-core

    2. Press t on your keyboard to activate the file finder.

    3. Identify a formula that looks most relevant, perhaps: Formula/mysql.rb, bringing you to a forumla file location: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb.

    4. Look at the revision history by clicking on the History button, which is located at https://github.com/Homebrew/homebrew-core/commits/master/Formula/mysql.rb. If you're interested in MySQL 5.7.10, you might want to click the latest revision prior to 5.7.11, which navigates to a GitHub commit:

      https://github.com/Homebrew/homebrew-core/commit/c77882756a832ac1d87e7396c114158e5619016c#Formula/mysql.rb

    NOTE: You may have to view the commit history in your console per GitHub's suggestion if the commit history does not load in your browser. Replace the commit SHA above in the URL if you're interested in seeing that commit on GitHub. Alternatively, skip to step 7, below.

    1. Click the "View" button to view the source for the mysql.rb file after the commit was applied.

    2. Then click the "Raw" button to view the raw source.

    3. Copy the URL. Alternatively, build the URL yourself with the mysql.rb file name to identify your formula and the particular version of that formula (identified by the commmit SHA in the URL below).

      https://raw.githubusercontent.com/Homebrew/homebrew-core/c77882756a832ac1d87e7396c114158e5619016c/Formula/mysql.rb

    4. Install it with $ brew install [URL from step 7]

      $ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/c77882756a832ac1d87e7396c114158e5619016c/Formula/mysql.rb
      

    NOTE: This answer was updated to account for the removal of the braumeister.org website. The same principle applies, braumeister had simply provided a beginner-friendly way to navigate formula versions.

    0 讨论(0)
  • 2020-11-21 12:02

    Update on the Library/Formula/postgresql.rb line 8 to

    http://ftp2.uk.postgresql.org/sites/ftp.postgresql.org/source/v8.4.6/postgresql-8.4.6.tar.bz2
    

    And MD5 on line 9 to

    fcc3daaf2292fa6bf1185ec45e512db6
    

    Save and exit.

    brew install postgres
    initdb /usr/local/var/postgres
    

    Now in this stage you might face the postgresql could not create shared memory segment error, to work around that update the /etc/sysctl.conf like this:

    kern.sysv.shmall=65536
    kern.sysv.shmmax=16777216
    

    Try initdb /usr/local/var/postgres again, and it should run smooth.

    To run postgresql on start

    launchctl load -w /usr/local/Cellar/postgresql/8.4.6/org.postgresql.postgres.plist
    

    Hope that helps :)

    0 讨论(0)
  • 2020-11-21 12:03

    I've discovered a better alternative solution then the other complex solutions.

    brew install https://raw.github.com/Homebrew/homebrew-versions/master/postgresql8.rb
    

    This will download and install PostgreSQL 8.4.8


    I found this solution by starting to follow the steps of searching the repo and a comment in the repo .

    After a little research found that someone has a collection of rare formulars to brew up with.


    If your looking for MySQL 5.1.x, give this a try.

    brew install https://raw.github.com/Homebrew/homebrew-versions/master/mysql51.rb
    
    0 讨论(0)
提交回复
热议问题