Setting up a Ruby/Rails Environment in Mountain Lion
So, I've just backed up about 500Gb of stuff on Laptop, formatted the HD, and installed Mountain Lion from the Recovery partition, all fairly simple, a bit time consuming , but I like to have a completely fresh system for new OS installs, and overtime I've been streamlining my approach.
First off, Xcode
Make sure you've got the latest Xcode, currently 4.4, then after that installs, you'll need to enable command line tools, Xcode -> Preferences -> Downloads
That should be all of Xcode setup and working for development, however, if you plan on using ruby 1.9.2 or earlier, you'll also need to install gcc-4.2 separately (via HomeBrew)
Homebrew
[HomeBrew][http://mxcl.github.com/homebrew] has become my standard package manager on OS X, It's pretty simple to setup, and works well out of the box
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
GCC
As Xcode no longer installs gcc, you'll have to install it manually before any ruby before 1.9.3. First you need to enable the homebrew-dupes repository, which gives you access to builds of Apples Open Source tools.
brew tap homebrew/dupes
brew install apple-gcc42
Databases
For now, we'll just setup MySql and Postgres as SQLite is included in OS X.
MySql is easy:
brew install mysql
Postgres is a bit more troublesome, and there appears to be a bug at the moment with Mountain Lion, which the current 'workaround' is to install without ossp-uuid. This works for me at the moment, but I'll be checking to see when this gets fixed.
Both databases will still require a bit more setting up, the commands to run will be output to the screen after you install them.
brew install postgresql --without-ossp-uuid
There will probably be plenty of other tools you'll need to install, but for me, the last big one is ImageMagick.
brew install imagemagick
This will prompt you to install Java (a necessary evil unfortunately).
RVM
All my rubies for development our managed by RVM, Very useful tool, and very simple to install.
curl -L https://get.rvm.io | bash -s stable --ruby
So, that should be enough to get a decent working development environment for Ruby/Rails projects, obviously you'll need to install rails and other project dependencies with bundler, but hopefully you be pretty used to those commands.
XQuarts
[XQuarts][http://xquartz.macosforge.org/landing] is needed if you plan on doing anything X11 related, just down and run the installer
Installing old Rubies with RVM
So, they setup earlier works fine for installing new rubies (i.e., 1.9.3), but it doesn't work so good for 1.8.7 and its bretheren. Now, I know these are old, and and you really shouldn't be using them anymore, but I still work on some old projects that require them. A simple change to your login environment should do the trick:
# in ~/.bash_profile or ~/.zshrc
export CC=/usr/local/bin/gcc-4.2
export CPPFLAGS=-I/opt/X11/include