---
title: The Hitchhiker's Guide to Riding a Mountain Lion
teaser:
tags: web,rails,osx
author: Prem Sichanugrist
published_on: 2012-07-25
---

*Update: A better approach is detailed in [Laptop Setup for an Awesome
Development Environment][laptop].*

[laptop]: https://thoughtbot.com/blog/laptop-setup-for-an-awesome-development-environment

![roar](http://media.tumblr.com/tumblr_m7p8rzVYgu1qcfyao.jpg)

Earlier today, [OS X Mountain Lion][OS X Mountain Lion] was released for all
users in the Mac App Store. As a member of the
[Mac Developer Program][Mac Developer Program], I decided to tame this wild cat
early on, jumping on the beta tester bandwagon since the Developer Preview 4.
Here are some of the things you should consider as you make the switch to this
shiny new operating system.

## The Upgrade Process

After I downloaded the 4GB installer from the Mac App Store, the whole upgrade
process took me about 45 minutes on my 15" 2010 Macbook Pro with an SSD drive.
It was a simple and straightforward process as the installer takes care of
everything.

Once the installer is done, we need to do some additional work to get up to
speed once again and be able to compile [Ruby][Ruby] (using [RVM][RVM] or
[rbenv][rbenv]) or install packages using [Homebrew][Homebrew]. Hold on to your
champagne for now.

## Getting Xcode + Command Line Tools Installed

You can get Xcode from the Mac App Store. You'll need at least version 4.4 of
Xcode for it to work with OS X Mountain Lion. After the installation, open up
Xcode in your `/Applications` folder. You'd want to go to Xcode -> Preferences
-> Downloads tab then install the "Command Line Tools." After you're done, quit
Xcode and fire up Terminal.

## Fix Homebrew + install GCC

After the upgrade, Apple will set the ownership of your `/usr/local` folder to
root. You can easily fix this by running this command in Terminal:

    sudo chown -R `whoami` /usr/local

Next, you need to update Homebrew:

    brew update

If you need to install any Ruby that's older than 1.9.3, such as 1.9.2, 1.8.7
or REE, you'll need to install GCC 4.2. Apple does not ship the Command Line
Tools with `gcc-4.2` compiler anymore (you can check by running `which
gcc-4.2`), so you need to install it via Homebrew. By default, Homebrew doesn't
include any formula that ships with the OS in the main repository, so you'll
have to enable [homebrew-dupes][homebrew-dupes] repository by using `brew tap`

    brew tap homebrew/dupes
    brew install apple-gcc42

Voila! Now you can compile any library that requires non-LLVM GCC.

**Note:** If you were using a binary package from MySQL website to install your MySQL server,  you will need to [change the ownership][homebrew ownership] of your MySQL data directory back by issue this command:

    sudo chown -R mysql:mysql `brew --prefix`/mysql

## Reinstall X11

Now, if you're still using some application that depend on X11, such as
[Divvy][Divvy] or [gitk][gitk], you'll need to install X11 as well. Apple has
[already removed X11 support][apple remove x11] from their operating system,
but you can still get the X11 package from [XQuartz][XQuartz]. I've been using
their 2.7.2 release, and it's working fine for me.

## Word to the Wise: Backup Your System

Before performing any major upgrade, always make sure that you have the latest
backup of your Mac. If you already have [Time Machine][Time Machine] set up,
all you need to do is [intiate another manual backup][manual backup]. It's also
a good idea to [verify your backup][verify backup] afterward to make sure that
it's working.

If you have been leading a carefree life and did not bother setting up Time
Machine, or would like to make sure that you can come back to Lion if something
is broken, I would suggest using [Carbon Copy Cloner][CCC] to clone your internal
hard drive to an external one. (Once the upgrade is done, I would still
recommend you set up Time Machine.)

## ROAR

Finally, your developer machine has been upgraded to OS X Mountain Lion. I hope
you'll enjoy the [new features][features] as much I do. Happy coding!

## Updates

When installing Ruby 1.8.7 with [rbenv][rbenv], there were compilation issues due to an issue with Tk. After digging through the output log, it turns out it was looking for an Xlib header and failing. This can be resolved by exporting an additional include path to GCC:

    export CPPFLAGS=-I/opt/X11/include

[manual backup]: http://osxdaily.com/2010/07/21/how-to-do-manual-backups-with-time-machine
[verify backup]: http://macs.about.com/od/backupsarchives/qt/Verify-Time-Machine-Backups.htm
[OS X Mountain Lion]: http://www.apple.com/osx
[Mac Developer Program]: https://developer.apple.com/programs/mac
[Golden Master]: http://en.wikipedia.org/wiki/Golden_master
[Time Machine]: http://www.apple.com/osx/apps/#time-machine
[CCC]: http://www.bombich.com
[RoaringApps]: http://roaringapps.com
[PowerPC]: http://en.wikipedia.org/wiki/PowerPC
[Rosetta]: http://en.wikipedia.org/wiki/Rosetta_(software)
[X11]: http://en.wikipedia.org/wiki/X11.app
[Divvy]: http://mizage.com/divvy
[Ruby]: http://ruby-lang.org
[RVM]: https://rvm.io/
[rbenv]: https://github.com/sstephenson/rbenv
[Homebrew]: http://brew.sh/
[homebrew-dupes]: https://github.com/Homebrew/homebrew-dupes
[gitk]: http://www.kernel.org/pub/software/scm/git/docs/gitk.html
[apple remove x11]: http://www.macrumors.com/2012/02/17/apple-removes-x11-in-os-x-mountain-lion-shifts-support-to-open-source-xquartz
[XQuartz]: http://xquartz.macosforge.org/landing
[growl notification center]: http://growl.posterous.com/going-forward-with-growl-and-notification-cen
[features]: http://www.apple.com/osx/whats-new
[homebrew ownership]: https://github.com/mxcl/homebrew/commit/66e4570c40b80cc79662f45a8a9be81665cfaa5e#README.md
