Recently I’ve heard about Max Howell‘s homebrew and Wayne E. Seguin’s rvm from a friend (caffo), and hearing that they were both pretty cool, I decided to give them a shot.
So if, like me, you are curious about these tools, I’ll post what I did to install them.
First I made backups (by moving some folders around)
mv ~/.gem ~/gems-old sudo mv /opt/local ~/macports-old
You could also install a gem called ‘rubygems_snapshot’ and do a
gem snapshot export ~/my_gem_list.yml
or a simple
gem list > ~/gem_list.txt
and just plain delete your user gem repository
rm -rf ~/.gem/
Of course I am assuming you were installing them in your home directory, why wouldn’t you be?
But if by any chance you have gems installed all over the place you could try running this instead (since this would remove the applicable executables as well):
sudo gem list | awk '{print $1}' | xargs sudo gem uninstall -a -x -i
Now let’s get started.
official installation instructions
Start by running:
ruby < <( curl 'http://gist.github.com/raw/323731/25f99360c7de3f72027d8fd07cb369b1c8756ea6/install_homebrew.rb' )
or download it from here and run it yourself.
If by any chance you don't trust or know what that does, you can test it by running the code below that calls this simple and safe ruby script first.
ruby < <( curl 'http://gist.github.com/raw/385387/0cacf4231fceb621c987221ee0aaa380be2bca5d/testing_download_and_run.rb' )
If you are curious, this is the source of that gist:
#!/usr/bin/env ruby puts 'Hello World'
Then install Xcode, I recommend downloading the latest version 3.2.2 at this moment from apple's website.
If you are the only person using your computer, you can change the ownership of /usr/local by doing a:
sudo chown -R $USER /user/local
Delete some folders:
rm -rf /usr/local/include rm -rf /usr/local/lib
After that you can start playing around with homebrew i.e.
brew install wget
I install most if not all of my stuff from brew now, even mysql and other things that I would rather not get from port.
Warning: do not remove your system's /usr/bin/ruby since brew depends on it.
(official installation instructions)
To Install/update from the github repository, which they recommend, run:
bash < <( curl 'http://rvm.beginrescueend.com/releases/rvm-install-head' )
I had a version of ree installed in /opt, so I just deleted it, I recommend that you do the same.
Add this to your .bash_profile or .bash_rc file, whichever you use.
source ~/.rvm/scripts/rvm
They advise you to put it at the end of it, and to make sure you have no returns inside your file.
I have a reload function in my file so I just ran reload
rvm install ree rvm install 1.9.1 rvm install 1.9.2-head
Set the one you use the most as the default one, at work is ree:
rvm ree --default
Everytime you open a new terminal, it should be using the default rvm ruby, but to make you might want to add the rvm-prompt feature to your default PS1. Add ~/.rvm/bin/rvm-prompt i v to your PS1 variable, something like:
# a fancy ps1 export PS1="\e[1;33m\u\e[0m|\e[1;32m\h\e[0m \e[1;34m\w\e[0m |\e[33m$(~/.rvm/bin/rvm-prompt i v)\e[0m|\n\$ "
If you want to install a gem for all of your rubies run
rvm gem install gemname
if not, you just use your regular gem to install stuff (it should be using the specific gem for your chosen ruby - as you can see below).
$ which ruby /Users/jao/.rvm/rubies/ree-1.8.7-2010.01/bin/ruby $ which gem /Users/jao/.rvm/rubies/ree-1.8.7-2010.01/bin/gem
I think that sums it up. Have fun!
And ask questions or say if something is wrong in the comments.