Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install specific version of Homebrew formula
brew update
brew versions FORMULA
cd `brew --prefix`
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions"
brew install FORMULA
brew switch FORMULA VERSION
git checkout -- Library/Formula/FORMULA.rb # reset formula
## Example: Using Subversion 1.6.17
#
# $ brew versions subversion
# 1.7.3 git checkout f8bf2f3 /usr/local/Library/Formula/subversion.rb
# 1.7.2 git checkout d89bf83 /usr/local/Library/Formula/subversion.rb
# 1.6.17 git checkout 6e2d550 /usr/local/Library/Formula/subversion.rb
# 1.6.16 git checkout 83ed494 /usr/local/Library/Formula/subversion.rb
# 1.6.15 git checkout 809a18a /usr/local/Library/Formula/subversion.rb
# 1.6.13 git checkout 7871a99 /usr/local/Library/Formula/subversion.rb
# 1.6.12 git checkout c99b3ac /usr/local/Library/Formula/subversion.rb
# 1.6.6 git checkout 8774131 /usr/local/Library/Formula/subversion.rb
# 1.6.5 git checkout a82e823 /usr/local/Library/Formula/subversion.rb
# 1.6.3 git checkout 6b6d369 /usr/local/Library/Formula/subversion.rb
# $ cd `brew --prefix`
# $ git checkout 6e2d550 /usr/local/Library/Formula/subversion.rb
# $ brew install subversion
# $ brew switch subversion 1.6.17
# $ git checkout -- Library/Formula/subversion.rb
@xster

This comment has been minimized.

Show comment
Hide comment
@xster

xster Jul 12, 2012

awesome, thanks!

xster commented Jul 12, 2012

awesome, thanks!

@ericstone57

This comment has been minimized.

Show comment
Hide comment
@ericstone57

ericstone57 Jul 31, 2012

great! Thanks!

great! Thanks!

@SoundLogic

This comment has been minimized.

Show comment
Hide comment
@SoundLogic

SoundLogic Oct 22, 2012

awesome!! thank you!!

awesome!! thank you!!

@sebastyuiop

This comment has been minimized.

Show comment
Hide comment
@sebastyuiop

sebastyuiop Dec 17, 2012

Perfect, thanks.

Perfect, thanks.

@calderon

This comment has been minimized.

Show comment
Hide comment
@calderon

calderon Feb 7, 2013

That' was perfect! The step cd brew --prefix saves my life! :D thanks

calderon commented Feb 7, 2013

That' was perfect! The step cd brew --prefix saves my life! :D thanks

@blissdev

This comment has been minimized.

Show comment
Hide comment
@blissdev

blissdev Mar 11, 2013

Very helpful, thank you!

Very helpful, thank you!

@jonmcewen

This comment has been minimized.

Show comment
Hide comment
@jonmcewen

jonmcewen Mar 27, 2013

Very useful for downgrading svn! What does the "brew switch" command do?

Very useful for downgrading svn! What does the "brew switch" command do?

@bekacho

This comment has been minimized.

Show comment
Hide comment
@bekacho

bekacho Apr 17, 2013

I upgraded tmux from 1.6 to 1.8 and things suddenly stop to work, so I did not need to install it again since it was already installed , so to downgrade :

brew switch tmux 1.6

Thank you for the gist !

bekacho commented Apr 17, 2013

I upgraded tmux from 1.6 to 1.8 and things suddenly stop to work, so I did not need to install it again since it was already installed , so to downgrade :

brew switch tmux 1.6

Thank you for the gist !

@ConnorDoyle

This comment has been minimized.

Show comment
Hide comment
@ConnorDoyle

ConnorDoyle May 14, 2013

👍
@jonmcewen -- brew switch appears to simply update the symlink in /usr/local/bin to the specified formula version in the Cellar.

👍
@jonmcewen -- brew switch appears to simply update the symlink in /usr/local/bin to the specified formula version in the Cellar.

@Leviathans

This comment has been minimized.

Show comment
Hide comment
@Leviathans

Leviathans Jul 10, 2013

when i brew update
error: Your local changes to the following files would be overwritten by merge:
Library/Formula/subversion.rb
Please, commit your changes or stash them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

when i brew update
error: Your local changes to the following files would be overwritten by merge:
Library/Formula/subversion.rb
Please, commit your changes or stash them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

@bingeboy

This comment has been minimized.

Show comment
Hide comment
@bingeboy

bingeboy Aug 13, 2013

Dude nice! I had 404 from all old versions of SVN but was able to manually drop in 1.7.11 into the svn folder and homebrew picked it up.

Dude nice! I had 404 from all old versions of SVN but was able to manually drop in 1.7.11 into the svn folder and homebrew picked it up.

@rainchen

This comment has been minimized.

Show comment
Hide comment
@rainchen

rainchen Aug 21, 2013

git checkout -- Library/Formula/FORMULA.rb this line is not working. I have to replace the -- with the hash of latest commit to get this work

git checkout -- Library/Formula/FORMULA.rb this line is not working. I have to replace the -- with the hash of latest commit to get this work

@rainchen

This comment has been minimized.

Show comment
Hide comment
@rainchen

rainchen Aug 28, 2013

I created a function version https://gist.github.com/rainchen/6363948
usage example:
$ brew-install ssh-copy-id 6.0p1

I created a function version https://gist.github.com/rainchen/6363948
usage example:
$ brew-install ssh-copy-id 6.0p1

@netsensei

This comment has been minimized.

Show comment
Hide comment
@netsensei

netsensei Jan 22, 2014

Works perfectly! Thx!

Works perfectly! Thx!

@hansenc

This comment has been minimized.

Show comment
Hide comment
@hansenc

hansenc Feb 4, 2014

When trying to install subversion 1.7.x, I got "Error: No available formula for serf". The workaround was:

$ brew tap homebrew/versions
$ brew install subversion17

as mentioned here. To switch back and forth between the two, you can use brew unlink and brew link.

hansenc commented Feb 4, 2014

When trying to install subversion 1.7.x, I got "Error: No available formula for serf". The workaround was:

$ brew tap homebrew/versions
$ brew install subversion17

as mentioned here. To switch back and forth between the two, you can use brew unlink and brew link.

@revolter

This comment has been minimized.

Show comment
Hide comment
@revolter

revolter Nov 1, 2016

There is no brew versions command.

revolter commented Nov 1, 2016

There is no brew versions command.

@PikalaxALT

This comment has been minimized.

Show comment
Hide comment
@PikalaxALT

PikalaxALT Jul 25, 2017

The brew versions command has been completely deprecated, and the tap has been drained.

The brew versions command has been completely deprecated, and the tap has been drained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment