I've just reinstalled my MacBook Pro with Mountain Lion, and I always start from scratch instead of doing an update, as I don't want to bring along old cruft - and it is a good way to make sure I don't bring infected/trojaned files (if there were any).
Here are the the (very terse) steps I took to get my Ruby development environment back up, more a reminder to myself than a installation cookbook, but I'm sure it will be helpful for someone...
Install Mountain Lion
Duh!
Install XCode
Available in the App Store, also make sure to install the command line tools.
Install rbenv
There is a chicken and egg problem here: to install
rbenv you need
git to clone the repo, and to install
git you need homebrew, and to install homebrew you need ruby. So work around that, pull down a tar-ball of the
rbenv first.
cd ~
mkdir tmp
cd tmp
wget https://github.com/sstephenson/rbenv/tarball/master
tar xf master
mv sstephenson-rbenv-* ~/.rbenv
Install Ruby
Add the following to
~/.gemrc to avoid generating ri & rdoc.
gem: --no-ri --no-rdoc
I use
yard instead, which is much nicer!
Get the latest version of Ruby from
http://www.ruby-lang.org/en/downloads/ (1.9.3-p194 at the time of writing)
cd ~/tmp
tar xzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194
./configure --prefix $HOME/.rbenv/versions/1.9.3-p194
make
make install
Also do the normal
rbenv in your
.bash_profile
Install homebrew
Now that
ruby is available,
homebrew can be installed
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
Install git
brew install git
Install libyaml
brew install libyaml
Reinstall rbenv & Ruby
Now we have all pieces to install
rbenv for real
cd ~
rm -rf .rbenv
git clone git://github.com/sstephenson/rbenv.git .rbenv
cd ~/tmp/ruby-1.9.3-p194
make distclean
./configure --prefix $HOME/.rbenv/versions/1.9.3-p194
make
make install
Install X11
Mountain Lion doesn't come with X11 headers any more, and if you try to compile Ruby 1.8 it requires X11 for tcl/tk, so it will fail with:
/usr/include/tk.h:78:23: error: X11/Xlib.h: No such file or directory
You can get X11 from
http://xquartz.macosforge.org/landing/
After that you need to set
export CPPFLAGS=-I/opt/X11/include
Install Ruby 1.8
If you don't need tcl/tk & X11 in Ruby 1.8 you can just supply the flags
--disable-tcl --disable-tk
to your
configure command, but if you do, you are now ready to compile 1.8
./configure --prefix $HOME/.rbenv/versions/1.8.7-p370
Done!
After this you are done!
martin@mbp[master]$ rbenv versions
1.8.7-p370
1.9.2-p320
* 1.9.3-p194 (set by /Users/martin/.rbenv/version)
Happy Ruby hacking :)