Skip to content

Instantly share code, notes, and snippets.

@achavez
Last active January 10, 2018 19:31
Show Gist options
  • Save achavez/bce495f5cb7a08d96d006ed2ede196c4 to your computer and use it in GitHub Desktop.
Save achavez/bce495f5cb7a08d96d006ed2ede196c4 to your computer and use it in GitHub Desktop.
Installing an old version of a Homebrew formula

Installing an old version of a Homebrew formula

Let's say, like me, you accidentally upgraded PostgresQL or PostGIS or something super important and now you need to go back in time and install the previous version.

  1. Find the commit of the old version that you want to install by looking through the Formula/ directory in the homebrew-core repo: https://github.com/Homebrew/homebrew-core/commits/master/Formula/ (If the above doesn't work, you'll need to clone the homebrew-core repo to your machine and run git log master -- Formula/<formula name>.rb).

  2. Unlink the existing (newer) version:

    $ brew unlink <formula_name>
  3. Install the old version using formula using a direct link to that commit:

    # For example, to install 9.3.2:
    $ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/aa049a47b218fda30f9a4a454119ae067a02cf50/Formula/postgis.rb
  4. Now you have both versions installed and your updated version should be the linked one:

    $ brew info postgis
    > postgis: stable 2.4.2 (bottled), HEAD
    > Adds support for geographic objects to PostgreSQL
    > https://postgis.net/
    > /usr/local/Cellar/postgis/2.3.2 (196 files, 75.2MB) *
    > Poured from bottle on 2018-01-10 at 12:48:54
    > /usr/local/Cellar/postgis/2.4.2 (228 files, 91MB)
    > Poured from bottle on 2018-01-10 at 11:54:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment