Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install older version of Formula in Homebrew
[From: http://hanxue-it.blogspot.com/2018/08/macos-homebrew-installing-older-version-of-software.html - just created a copy to keep it for long term]
Homebrew always wants to install the latest version of the Formula (software). This is by design, because every time there is an update to a formula, it wants to be tested against all the other formulas that it depends on. Mixing new and old versions of software is a recipe for incompatibility disaster.
But sometimes there are situations where you need an older version of software. In my specific case, Yarn was compiled against an older version of icu4c, and I want that older version instead of recompiling Yarn.
$ yarn install
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.61.dylib
Referenced from: /usr/local/bin/node
Reason: image not found
Trace/BPT trap: 5
Listing Older Versions
First, let's get to the location where the homebrew Formulas are stored.
$ cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
Next, we need to look for the git to commit to the version we want
$ git log --follow icu4c.rb
commit c179a064276d698d66953898ff9e02d6e0664b2a
Author: BrewTestBot <brew-test-bot@googlegroups.com>
Date: Wed Aug 15 21:51:09 2018 +0000
icu4c: update 62.1 bottle.
commit 2235a91cedb2038a7c721796b48e63836c792607
Author: ilovezfs <ilovezfs@icloud.com>
Date: Tue Jul 24 09:44:31 2018 +0200
icu4c: remove head spec (#30427)
commit e6b65d7433d0a18c36eb584be554500b6ec06884
Author: BrewTestBot <brew-test-bot@googlegroups.com>
Date: Fri Jun 22 02:12:37 2018 +0000
icu4c: update 62.1 bottle.
commit 004bdfeef173becdc7e1344a4c095945a97ca410
Author: Chongyu Zhu <i@lembacon.com>
Date: Thu Jun 21 08:27:56 2018 +0800
icu4c 62.1
commit 6d98155ab46f61482f16f8bcffb378a0a71e0d15
Author: BrewTestBot <brew-test-bot@googlegroups.com>
Date: Thu Mar 29 06:16:10 2018 +0000
icu4c: update 61.1 bottle.
commit 3f4b2375618b730d038c6a739170bf44af8ba5a0
Author: commitay <commitay@users.noreply.github.com>
Date: Tue Mar 27 08:02:19 2018 +1000
icu4c 61.1
Now that we have committed the commit 6d981, we can create a new branch with that commit
$ git checkout -b icu4c-61.1 6d9815
Switched to a new branch 'icu4c-61.1'
Then we can proceed to install the Formula
$ brew reinstall ./icu4c.rb
Then I can switch to the older version
$ brew switch icu4c 61.1
@t0b1hh
Copy link

t0b1hh commented Mar 24, 2021

Thank you 🙏

Helped me repairing my homebrewed ssh/git setup on an old El Capitan system today.

@njoguamos
Copy link

njoguamos commented May 4, 2021

This worked for me. I was able to downgrade from PHP 8.0.5 to PHP 8.0.3_1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment