Skip to content

Instantly share code, notes, and snippets.

@sawant
Last active March 16, 2024 05:35
Show Gist options
  • Save sawant/6ea10e45de7d09e966a1dc6afea3bffb to your computer and use it in GitHub Desktop.
Save sawant/6ea10e45de7d09e966a1dc6afea3bffb to your computer and use it in GitHub Desktop.
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 <[email protected]>
Date: Wed Aug 15 21:51:09 2018 +0000
icu4c: update 62.1 bottle.
commit 2235a91cedb2038a7c721796b48e63836c792607
Author: ilovezfs <[email protected]>
Date: Tue Jul 24 09:44:31 2018 +0200
icu4c: remove head spec (#30427)
commit e6b65d7433d0a18c36eb584be554500b6ec06884
Author: BrewTestBot <[email protected]>
Date: Fri Jun 22 02:12:37 2018 +0000
icu4c: update 62.1 bottle.
commit 004bdfeef173becdc7e1344a4c095945a97ca410
Author: Chongyu Zhu <[email protected]>
Date: Thu Jun 21 08:27:56 2018 +0800
icu4c 62.1
commit 6d98155ab46f61482f16f8bcffb378a0a71e0d15
Author: BrewTestBot <[email protected]>
Date: Thu Mar 29 06:16:10 2018 +0000
icu4c: update 61.1 bottle.
commit 3f4b2375618b730d038c6a739170bf44af8ba5a0
Author: commitay <[email protected]>
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
@njoguamos
Copy link

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

@mustafabekec
Copy link

# Intel
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
# M1
cd $(brew --prefix)/Library/Taps/homebrew/homebrew-core/Formula

git checkout -b icu4c-69 c278d3dc42a6aac6ad7a46bd7d638c305364a888

brew reinstall ./icu4c.rb

brew info icu4c # Make sure it's 69.1

brew pin icu4c

git checkout master

https://gitlab.com/gitlab-org/gitlab-development-kit/-/issues/1450

@lab0ryu
Copy link

lab0ryu commented Mar 16, 2024

Thank you 🙏

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