How do I install a specific version of a formula in homebrew? For example, postgresql-8.4.4 instead of the latest 9.0.




7 Answers

up vote 64 down vote accepted

Since the whole formula directory is a git repository, one can install specific versions using plain git commands.

First, we’ll need to find a commit where postgresql 8.4.4 was available. One way to do this is using git log. (I assume we are in the base directory of homebrew. Probably /usr/local.)

$ git log -S'8.4.4' -- Library/Formula/postgresql.rb

git log -S looks for all commits in which the string '8.4.4' was either added or removed in the file Library/Formula/postgresql.rb. We get two commits as a result.

commit 7dc7ccef9e1ab7d2fc351d7935c96a0e0b031552
Author: Aku Kotkavuo
Date:   Sun Sep 19 18:03:41 2010 +0300

    Update PostgreSQL to 9.0.0.

    Signed-off-by: Adam Vandenberg

commit fa992c6a82eebdc4cc36a0c0d2837f4c02f3f422
Author: David Höppner
Date:   Sun May 16 12:35:18 2010 +0200

    postgresql: update version to 8.4.4

Obviously, fa992c6a82eebdc4cc36a0c0d2837f4c02f3f422 is the commit we’re interested in.

$ git checkout -b postgresql-8.4.4 fa992c6a82eebdc4cc36a0c0d2837f4c02f3f422
$ brew install postgresql
$ git checkout master
$ git branch -d postgresql-8.4.4

You may skip the last command to keep the reference in your git repository.

One note: When checking out the older commit, you temporarily downgrade your homebrew installation. So, you should be careful as some commands in homebrew might be different to the most recent version.

Update: As of August 2011, homebrew has a brew versions command, which spits out all available versions with their respective SHA hashes.


$ brew versions postgresql
9.0.4    git checkout 2accac4 /usr/local/Library/Formula/postgresql.rb
9.0.3    git checkout b782d9d /usr/local/Library/Formula/postgresql.rb
9.0.2    git checkout 2c3b88a /usr/local/Library/Formula/postgresql.rb
9.0.1    git checkout b7fab6c /usr/local/Library/Formula/postgresql.rb
9.0.0    git checkout 1168d8f /usr/local/Library/Formula/postgresql.rb
8.4.4    git checkout c32bea0 /usr/local/Library/Formula/postgresql.rb

These commit hashes are probably better than the git log -S approach, because they seem to include also later fixes and changes to the formula files. git log -S would always show the point where the version changed, not including any later additions to that formula.

(And of course it is pretty neat that the output includes everything one needs to do in order to install the old formula.)

You can also just checkout the formula using git checkout fa992 -- Library/Formula/postgresql.rb. When you're done, you can undo the changes to the formula using git revert HEAD Library/Formula/postgresql.rb && git checkout -- Library/Formula/postgresql.rb. – mipadi Jan 3 '11 at 20:59
Postgresql v8.4.4 is no longer at the ftp server that the formula refers to. It is easy, though, to change the formula to reference the 8.4.6, which may work for you. The MD5 in the formula also needs to change - the correct MD5 will be reported when you try to brew install. – Swards May 3 '11 at 21:55
Note: on a fresh Homebrew install, you may need to brew update to establish its Git repo. – Bluu May 28 '11 at 0:57
I'm a brew newbie (brewbie?) and I ran the git checkout ... for a specific mysql version, but now what? I tried brew install mysql at this point, but I get Error: This is a head-only formula; install with "brew install --HEAD mysql". Then I try brew install --HEAD mysql and I get Error: No head is defined for mysql. Am I missing something obvious? – istrasci Jan 9 at 21:06

There's now a much easier way to install an older version of a formula that you'd previously installed. Simply use

brew switch [formula] [version]

For instance, I alternate regularly between Node.js 0.4.12 and 0.6.5:

brew switch node 0.4.12
brew switch node 0.6.5

Since brew switch just changes the symlinks, it's very fast. See further documentation on the Homebrew Wiki under External Commands.

I tried this, and it succeded with the message " 33 links created for /usr/local/Cellar/node/0.4.7 " , but when I run node afterwards, it fails with the message " -bash: /usr/local/bin/node: No such file or directory " . Any idea what couldlve gone wrong? Note: i downloaded 0.4.7 manually and put it in the cellar directory, because I dont know how to download anyhting but the latest node version using brew. – Soroush Hakami Dec 22 '11 at 21:36
@Souroush Hakami you can't just put it in the folder, you have to put the compiled version in the Cellar folder. – aledalgrande Mar 2 at 23:49

I've discovered a better alternative solution then the other complex solutions.

brew install

This will download and install PostgreSQL 8.4.8

I found this solution by starting to follow the steps of searching the repo and a comment in the repo .

After a little research found that someone has a collection of rare formulars to brew up with.

If your looking for MySQL 5.1.x, give this a try.

brew install

Thanks for reading.


I just used Homebrew to go back to Maven 2.2.1 since the simple brew install maven installed Maven 3.0.3.

First I Un-installed Maven using:
$ brew remove maven
Uninstalling /usr/local/Cellar/maven/3.0.3...

Then I listed all available version of maven:
$ brew versions maven
3.0.3 git checkout 14e4db3 /usr/local/Library/Formula/maven.rb
3.0.2 git checkout 03b288a /usr/local/Library/Formula/maven.rb
3.0.1 git checkout 83857d6 /usr/local/Library/Formula/maven.rb
3.0 git checkout 09a0264 /usr/local/Library/Formula/maven.rb
2.2.1 git checkout d40d419 /usr/local/Library/Formula/maven.rb

I just copied and pasted the git check out command I needed to grab version 2.2.1 then called the regular brew install command, and now it has version 2.2.1.
$ git checkout d40d419 /usr/local/Library/Formula/maven.rb
$ brew install maven
==> Downloading
######################################################################## 100.0%
/usr/local/Cellar/maven/2.2.1: 10 files, 3.1M, built in 3 seconds
$ mvn --version
Apache Maven 2.2.1 (r801777; 2009-08-06 12:16:01-0700)

This is exactly what I wanted thanks! – micmcg Mar 8 at 6:08

Update on the Library/Formula/postgresql.rb line 8 to

And MD5 on line 9 to


Save and exit.

brew install postgres
initdb /usr/local/var/postgres

Now in this stage you might face the postgresql could not create shared memory segment error, to work around that update the /etc/sysctl.conf like this:


Try initdb /usr/local/var/postgres again, and it should run smooth.

To run postgresql on start

launchctl load -w /usr/local/Cellar/postgresql/8.4.6/org.postgresql.postgres.plist

Hope that helps :)


Simple Workflow

Step 1:

Navigate to your homebrew base directory (usually this is /usr/local)

Step 2:

Enter brew versions FORMULANAME (FORMULANAME is the formula you want to install).

You will then get something like:

1.0.1 git checkout 1234567 Library/Formula/FORMULANAME.rb
1.0.0 git checkout 0123456 Library/Formula/FORMULANAME.rb

Step 3:

Choose you the desired version and check it out via copy and paste of the desired version line (leave out the version number in the beginning).

Example for getting 1.0.0:

git checkout 0123456 Library/Formula/FORMULANAME.rb

Step 4:

brew install FORMULANAME

Step 5:



Your Answer

  • Images are exactly like links, but they have an exclamation point in front of them:

    ![a busy cat](
    ![two muppets][1]
     [1]: "tooltip"

    The word in square brackets is the alt text, which gets displayed if the browser can't show the image. Be sure to include meaningful alt text for screen-reading software.

    Be sure to use text styling sparingly; only where it helps readability.

    *This is italicized*, and so
    is _this_.
    **This is bold**, just like __this__.
    You can ***combine*** them
    if you ___really have to___.

    To break your text into sections, you can use headers:

    A Large Header
    Smaller Subheader

    Use hash marks if you need several levels of headers:

    # Header 1 #
    ## Header 2 ##
    ### Header 3 ###

    Both bulleted and numbered lists are possible:

    - Use a minus sign for a bullet
    + Or plus sign
    * Or an asterisk
    1. Numbered lists are easy
    2. Markdown keeps track of
       the numbers for you
    7. So this will be item 3.
    1. Lists in a list item:
        - Indented four spaces.
            * indented eight spaces.
        - Four spaces again.
    2.  You can have multiple
        paragraphs in a list items.
        Just be sure to indent.
    > Create a blockquote by
    > prepending “>” to each line.
    > Other formatting also works here, e.g.
    > 1. Lists or
    > 2. Headings:
    > ## Quoted Heading ##

    You can even put blockquotes in blockquotes:

    > A standard blockquote is indented
    > > A nested blockquote is indented more
    > > > > You can nest to any depth.

    To create code blocks or other preformatted text, indent by four spaces:

        This will be displayed in a monospaced font. The first four spaces
        will be stripped off, but all other whitespace will be preserved.
        Markdown and HTML are turned off in code blocks:
        <i>This is not italic</i>, and [this is not a link](

    To create not a block, but an inline code span, use backticks:

    Press the `<Tab>` key, then type a `$`.

    If you want to have a preformatted block within a list, indent by eight spaces:

    1. This is normal text.
    2. So is this, but now follows a code block:
            Skip a line and indent eight spaces.
            That's four spaces for the list
            and four to trigger the code block.

    If you need to do something that Markdown can't handle, use HTML. Note that we only support a very strict subset of HTML!

    Strikethrough humor is <strike>funny</strike>.

    Markdown is smart enough not to mangle your span-level HTML:

    <b>Markdown works *fine* in here.</b>

    Block-level HTML elements have a few restrictions:

    1. They must be separated from surrounding text by blank lines.
    2. The begin and end tags of the outermost block element must not be indented.
    3. Markdown can't be used within HTML blocks.

        You can <em>not</em> use Markdown in here.

Not the answer you're looking for? Browse other questions tagged or ask your own question.