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

This comment has been minimized.

Copy link

@Schwad Schwad commented Dec 6, 2019

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

@vlad7code

This comment has been minimized.

Copy link

@vlad7code vlad7code commented May 22, 2020

Hi,

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

commit 22fb699a417093cd1440857134c530f1e3794f7d
Author: Bo Anderson <mail@boanderson.me>
Date:   Thu Apr 23 14:37:03 2020 +0000

    icu4c: update 66.1 bottle.

commit c78114de1252ac63590b06c1f2325e576a5d5226
Author: Pavel Omelchenko <p.Omelchenko@gmail.com>
Date:   Fri Apr 3 00:58:01 2020 +0300

    icu4c 66.1

commit 7b53db18125dcb52ff5cbf7ffd98747cd3776546 (grafted)
Author: Michka Popoff <michkapopoff@gmail.com>
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

This comment has been minimized.

Copy link

@taynv28892 taynv28892 commented Jun 9, 2020

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

This comment has been minimized.

Copy link

@Thirdwrist Thirdwrist commented Jul 7, 2020

This is amazing! works for me

@veryprivate

This comment has been minimized.

Copy link

@veryprivate veryprivate commented Oct 17, 2020

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

This comment has been minimized.

Copy link

@juliapolbach juliapolbach commented Nov 10, 2020

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

@t0b1hh

This comment has been minimized.

Copy link

@t0b1hh t0b1hh commented Mar 24, 2021

Thank you 🙏

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

@njoguamos

This comment has been minimized.

Copy link

@njoguamos 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