Compiling with Homebrew without XCode
I’m a big fan of not installing XCode on new Macs. I just don’t think it’s necessary, unless you’re genuinely building OS X or iOS applications.
First of all, download and install those command line tools. You’re going to need those first of all.
Next, install Homebrew. There are instructions on the site, but the quick version is:
Once homebrew install installed, you need to install another version of
gcc (A compiler). There is a version of this that already comes with OS X, but it’s pretty old.
Enable the dupes homebrew package, and install an up-to-date version of GCC:
Theoretically, you now have the compilers, utilities, and tools you need to set up a range of packages on your Mac. One last problem that I’ve run into installing packages such as
node, however, are programs that are run from the compilers to try and find XCode - and fail when they find it is not installed. The error looks something like this:
The solution for this is to tell these tools that Xcode is ‘installed’ in
/usr/bin - where all the compilers are installed:
This stops xcode-select from erroring out and halting the compile process, by ensuring that it tries to find the compilers that it requires by looking in the directory where they are already installed.
Once all these steps are completed, you should have a full set of developer tools installed - all you need to compile almost all of the many Homebrew recipes that are available.
Note: The original instructions for setting up command-line tools and gcc-4.2 come from: http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion. The
xcode-select fix comes from this issue report on the Homebrew repository