lqphzg
Last Updated: February 25, 2016
·
39.37K
· rubenrails
6fce1175151b0668f66e36bcfe5c3994

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

Done!

9 Responses
Add your response

2428
94939a9f502a27d08d9dc15a386a2585

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 ·
3445
Cfd84a9daccbe0eedd3899f728e3db7f

Thanks for this - very cool!

over 1 year ago ·
4968
F7aadd9c3f091c013076441ee87adcbf

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: http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula

over 1 year ago ·
5434
3d6067fe8e36a73ac01f0485095a6df2

Great tip, thanks!

over 1 year ago ·
9494
7a8018c1a12badb1daee27cb54dd04f3

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 ·
10308
8d943d05291180fae0976a9015e6f73a

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

over 1 year ago ·
11644
458641ed4b2725b16edbf0192ca0b2f2

Clear and simple ! Thank you !

over 1 year ago ·
12350
0e8a012c6542299bec2bc94922a3ed27

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

over 1 year ago ·
13654
Decadenza

You just saved my day. Thank you!

over 1 year ago ·