I recently purchased a new Mac, and needed to set up my development environment again; I thought I’d record the steps taken, in case it helps anyone else out in a similar position.
Starting with version 4.3, Xcode no longer ships with command line developer tools, like gcc
; instead, they are available as an optional component to Xcode and as a download separate from Xcode.
And, since Ruby 1.9.3 supports being compiled with LLVM/clang, I thought I’d try setting up my environment without Xcode and without the OSX GCC Installer.
Installation steps
- Run OS X’s “Software Update”, to make sure the operating system and built-in software are up-to-date.
- Download and install Command Line Tools for Xcode.
-
Install Homebrew:
$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
-
Install Git:
$ brew install git
-
Install rbenv:
$ cd $ git clone git://github.com/sstephenson/rbenv.git .rbenv $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_login $ echo 'eval "$(rbenv init -)"' >> ~/.bash_login
-
Install ruby-build:
$ mkdir -p ~/.rbenv/plugins $ cd ~/.rbenv/plugins $ git clone git://github.com/sstephenson/ruby-build.git
-
Install Ruby 1.9.3:
$ CC=/usr/bin/clang rbenv install 1.9.3-p194
-
Set Ruby 1.9.3 as global version to use:
$ rbenv global 1.9.3-p194
Note:
In steps 3, 5 and 6, I’m showing you the commands I used, which are based on the respective tool’s current installation guide; but, those commands are subject to change. Also, in step 3, I’m using the version of Ruby that ships with OS X.
Result
Homebrew makes sure you are well aware that its support of using “Command Line Tools” without Xcode is experimental:
Error: Experimental support for using the “Command Line Tools” without Xcode. Some formulae need Xcode to be installed (for the Frameworks not in the CLT.)
Despite that, I have not had any trouble installing anything I’ve needed so far – including: PostgreSQL, ImageMagick and Qt. Likewise, I haven’t had any trouble running any Ruby/Rails applications.