Last Updated: September 09, 2019
· rubenrails

brew install specific version of formula

Lets say we want to install (or downgrade to) node 0.6.19 instead of the newest version.

If you already have node, uninstall current version with:

$ brew uninstall node

Then search for available versions of the formula:

$ brew versions node
0.8.3    git checkout 31f8d9f Library/Formula/node.rb
0.8.2    git checkout 50ae8e4 Library/Formula/node.rb
0.8.1    git checkout 9ff0a1d Library/Formula/node.rb
0.8.0    git checkout 01f8006 Library/Formula/node.rb
0.6.19   git checkout 83988e4 Library/Formula/node.rb

Now checkout the desired version. Assuming you're at /usr/local/:

$ git checkout 83988e4 Library/Formula/node.rb

Finally install node:

$ brew install node


9 Responses
Add your response

Thanks for the clear instructions. I'd gotten as far as "brew versions ...", but it was unclear that I needed to actually check out the older version and reinstall.

This is particularly useful with "brew switch <package> <new version number>

over 1 year ago ·

Thanks for this - very cool!

over 1 year ago ·

There's a much easier way, you don't need to uninstall! Just use brew tap homebrew/versions, brew install node08, brew unlink node and brew link node08 for example to switch back to 0.8 from 0.10.

For more explanation see:

over 1 year ago ·

Great tip, thanks!

over 1 year ago ·

It's important to note you have to be in the working directory of the git repository for it to work. Otherwise you get an error:

"fatal: Not a git repository (or any of the parent directories): .git"

In the example above, you want to be in the Library/Formula folder when you attempt the git checkout.

over 1 year ago ·

@ulysseous: Make sure you are in /usr/local/ directory and then checkout

over 1 year ago ·

Clear and simple ! Thank you !

over 1 year ago ·

brew versions <XXX>
Warning: brew-versions is unsupported and may be removed soon.
Please use the homebrew-versions tap instead:

over 1 year ago ·

You just saved my day. Thank you!

over 1 year ago ·