Make sure that you have the latest version of Xcode installed from the Mac App Store, and that you have the command line tools installed. To install the command line tools, open Xcode, click Xcode->Preferences->Downloads->Command Line Tools
Install brew if needed.
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"