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
@Schwad
Copy link

Schwad commented Dec 6, 2019

This is amazing and saved my day. Thank you @sawant

@vlad7code
Copy link

Hi,

I ran git log --follow icu4c.rb and all the output is:

commit 22fb699a417093cd1440857134c530f1e3794f7d
Author: Bo Anderson <[email protected]>
Date:   Thu Apr 23 14:37:03 2020 +0000

    icu4c: update 66.1 bottle.

commit c78114de1252ac63590b06c1f2325e576a5d5226
Author: Pavel Omelchenko <[email protected]>
Date:   Fri Apr 3 00:58:01 2020 +0300

    icu4c 66.1

commit 7b53db18125dcb52ff5cbf7ffd98747cd3776546 (grafted)
Author: Michka Popoff <[email protected]>
Date:   Thu Feb 13 07:19:53 2020 +0100

    node@10: Add comment about Python 3 support (#50077)

What should I do? Thank you!

@taynv28892
Copy link

Hi,
I got issue mismatch SHA256 key.

==> Downloading https://homebrew.bintray.com/bottles/icu4c-64.2.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/e8/e858556120acc0c2d52b8fb572b677856724cc28d24a7e1b2762d458a2977c8e?__
######################################################################## 100.0%
Error: SHA256 mismatch
Expected: e707bf5e3d0189ede7d941d95a417b5dacad3eac99b9a677042464140f12fa1d
Actual: e858556120acc0c2d52b8fb572b677856724cc28d24a7e1b2762d458a2977c8e
Archive: /Users/macbook/Library/Caches/Homebrew/downloads/85517172585f53ec6345bbab70673ae252f1fb92de862d669bd47db314e40162--icu4c-64.2.mojave.bottle.tar.gz
To retry an incomplete download, remove the file above.

Please help me solve it. Thanks

@Thirdwrist
Copy link

This is amazing! works for me

@veryprivate
Copy link

Disclaimer: I have used this method for a different tap. I have zero knowledge about these particular taps, libraries, or programs.

@vlad7code and taynv28892

There was an update to the software for version 61.1 and hence SHA hash changed.

What should I do? Thank you!

cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
git checkout 6d9815
brew reinstall ./icu4c.rb
git checkout master

@juliapolbach
Copy link

This worked perfectly, saved my day, thanks! <3

@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

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