How to install a previous version of a package with Homebrew

homebrew-256x256

Homebrew is an awesome package manager.  For their home page see https://brew.sh/.  However they did some refactoring in April 2017, and a lot of the information online on how to go back to a previous version of a package no longer works.

In my particular case I needed emscripten 1.36.5, and brew was giving me 1.37.10.  Replace emscripten in the Terminal commands below with your particular package.

  • brew tap homebrew/core –full
  • cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
  • brew log –oneline emscripten

You will see git hash on the left column, and the bunch of versions on the right column. example below.  Take note of the git hash that corresponds to the package version you want. In my case I want 1.36.5, so I choose d876a63 .

555a07d emscripten: update 1.37.10 bottle.
b590498 emscripten 1.37.10
53f53f6 emscripten: update 1.37.1 bottle.
bbd3cc2 emscripten 1.37.1
d2b06b4 emscripten: fix caveats
53507df emscripten: update 1.37.0 bottle.
8a660ec emscripten 1.37.0
d905802 emscripten: update 1.36.14 bottle.
e73e793 emscripten 1.36.14
0ea5a49 emscripten: fix HEAD build (#6475)
5229d2d emscripten: update 1.36.13 bottle.
5dee768 emscripten 1.36.13
7a4dabf Use hash rockets again. (#5177)
3036601 Use Ruby 1.9+ symbol hash keys in all formulae. (#4942)
d876a63 emscripten: update 1.36.5 bottle.
1bea73c emscripten: update 1.36.5 bottle.
dc4a4ce emscripten 1.36.5
72a78d4 emscripten: update 1.36.4 bottle.
a94599d emscripten 1.36.4
3194b7f emscripten: update 1.36.3 bottle.

  • git checkout d876a63
  • export HOMEBREW_NO_AUTO_UPDATE=1
  • brew install emscripten

You should check the terminal output that the old version that you want is now being installed

  • unset HOMEBREW_NO_AUTO_UPDATE
  • brew pin emscripten
  • git checkout master

At this point emscripten is now pinned to 1.36.5 and won’t get upgraded accidentally.

Leave a Reply