This guide is intended for you who in need to install specific version of a homebrew formula, usually older version :-)

    go to homebrew dir

    cd "$(brew --repo homebrew/core)"
    

    we need a full clone to view all commit logs, by default it’s shallow clone

    git -C "$(brew --repo homebrew/core)" fetch --unshallow
    

    find out the version in commit log, i.e. mine is solr version 6.6.x

    git log Formula/solr.rb
    

    result would be like follows:

    commit 39bcac0377155f97b0edd28bea731dd1b14b9c99
    Author: Ryan Baumann <[email protected]>
    Date:   Thu Jun 29 06:16:38 2017 -0400
    
        solr 6.6.0 (#15004)
    

    fine, we create a new branch for the intended version

    git checkout -b solr-660 39bcac0377155f97b0edd28bea731dd1b14b9c99
    

    install this version with auto update turned off

    HOMEBREW_NO_AUTO_UPDATE=1 brew install solr
    

    all goods? great! lets clean up the changes we’ve made

    git checkout master
    git branch -d solr-660
    

    Notes:


    I found an issue while installing this version

    Error: Failed to install plist file
    Error: undefined method `undent' for #<String:0x00007f9f4e97df48>
    

    it’s an open issue, with easy workaround describe here, mine would be manually remove .undent at solr.rb file before installing.

    /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/solr.rb
    

    Done :-)

    © 2018 Komang. All Rights Reserved.

    Made with in Kuta, Bali, Indonesia

    Proudly published with Hugo