public
Last active

Install specific version of Homebrew formula

  • Download Gist
gistfile1.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
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

awesome, thanks!

awesome!! thank you!!

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

Very helpful, thank you!

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

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 !

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

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

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.

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

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

Works perfectly! Thx!

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.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.