Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save D4v1X/5084438 to your computer and use it in GitHub Desktop.
Save D4v1X/5084438 to your computer and use it in GitHub Desktop.
Installing Ruby, Rails, Git & Homebrew on Mountain Lion 10.8.2

#1. Install Command Line Tools 10.8 for Xcode

In order to compile Ruby with RVM, as well as many Homebrew packages, you'll need a compilation toolchain. If you are doing Mac or iOS development, you may want to install Xcode in its entirety. However if you don't want the hefty Xcode (1.8GB) on your system, the Command Line Tools are a good lightweight (110MB) alternative.

The Command Line Tools installer can be downloaded here (you'll need an Apple ID). After downloading, mount the disk image and run the installer.

The first command we will run will serve to verify that Xcode successfully installed GCC:

gcc --version

#2. Install Ruby and Rails using RVM

Note: the following commands should be run as a non-root user (i.e. no sudo).

To install the latest stable version of RVM, run the following from a terminal window:

$ curl -L https://get.rvm.io | bash -s stable

Close and reopen the terminal window. Then install the latest Ruby version with:

$ rvm install 1.9.3

ERROR Compilation:

export CC=gcc

You can confirm this has installed correctly by running:

$ ruby -v
ruby 1.9.3p327 (2012-11-10) [x86_64-darwin12.2.0]

Then we can install and verify Rails with the following commands:

$ gem install rails
$ rails -v
Rails 3.2.9

NOTE:

Before you install Ruby with RVM, you should make sure you have the latest version of RVM:

$ rvm get head

You should also read carefully through the requirements after running this command:

$ rvm requirements

#3. Install Homebrew

Homebrew is my preferred way of managing packages in OS X. Homebrew compiles most packages from source and keeps everything nicely managed within /usr/local. It can be installed by running:

$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"

Once the installation is successful, run the following command:

brew doctor

Warnings:

#4. Install Git

Git is the version control system of choice among many web developers. With Homebrew, installing Git is as easy as this:

brew install git

Once the installation is successful, run the following command:

brew doctor

Warnings:

Warning: /usr/bin occurs before /usr/local/bin

If you see that warning, run this:

$ echo 'export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"' >> ~/.bash_profile

This command takes everything between the single quotes and adds it (>>) to a file called .bash_profile in your user’s root directory (~/). Every time you open a new Terminal window or tab, .bash_profile is called. The export PATH line tells your system to look in /usr/local/bin first. This is important because Xcode installs an older version of Git in /usr/bin, but we want to use the latest version that Homebrew installed in /usr/local/bin.

Quit and relaunch Terminal, then run brew doctor once more. Your system should be raring to brew now.

To verify:

$ which git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment