How to (re)create development and build tools on a corrupt installation

homebrewunixxcode

On my previous computer I had Xcode working nicely; on my present computer, with Homebrew installed, gcc and make are present in /Developer/usr/bin but not /usr/bin. On the whole when I try to download and build http://JonathansCorner.com/download/tms1_4.tar.gz, I can find bits and pieces of the tools used to do things, but when invoked from its present path it doesn't recognize #include <stdio.h> type includes.

How can I reinstall Xcode, Homebrew, and anything else to get a fresh and working build so I can run make && make install?

Best Answer

Reinstalling XCode and updating Homebrew should be enough. To do this:

  • Try the uninstall-devtools script from this answer to remove older XCode versions. (If it doesn't work or you can't find it, don't worry about it.)
  • Delete the entire /Developer directory if it exists. This is where older versions of XCode live.
  • Download and install the latest XCode for your OS version. (The App Store makes this easy.)
  • Install the Command Line Tools. In XCode, go to the Apple menu, select Preferences, select the Downloads section, and click Install next to Command Line Tools.
  • Update the Homebrew definitions and packages with brew update && brew upgrade.
    • If any brewed packages still seem broken, brew rm them and brew install --fresh to reinstall.
  • Edit your shell config file (e.g. ~/.bashrc) to make sure /usr/local/bin is on your path. brew doctor can help diagnose this and other issues.

Note that tms is designed to install to /usr/lib by default, which you won't have permissions to do in a normal OS X setup even once you have all the tools installed, because the OS reserves /usr for its own use. You'll probably want to fiddle with the Makefile and tms.h to get it in to /usr/local or /opt, which are easier places to drop user-built packages.

If you're feeling ambitious, you could even do brew create http://jonathanscorner.com/download/tms1_4.tar.gz to make a Homebrew formula for TMS, making repeated installs easier.