Ever had some strange things happen on the Mac command line? Have you installed or updated Xcode recently? The issue is most likely related to the command line tools. Before you tear your hair out, make sure you check these possible solutions first.
Sorry to disappoint but there’s really only three main things to look for.
1. Have you installed the command line tools?
Xcode itself isn’t enough to do non-iOS development. You need to install the command line tools which are an additional package you can download and install from within Xcode. Just go to the Xcode preferences and then to “Locations” or “Downloads” and look for the button that allows you to download and install the command line tools. This is also available as a standalone package but I prefer to have Xcode even if I don’t use it often if at all.
2. Have you selected the correct version of Xcode tools?
I recently installed the new Xcode 6 Beta and suddenly things broke (related to #3 coming up). Some tools are at different versions or don’t exist at all in the command line tools depending on the version of Xcode you use. The fix is to go into the preferences again and where you installed the command line tools there will be an option to choose a version of the Xcode command line tools. Make sure a version is selected. If one is already selected you probably just need to change it to the alternative one that isn’t currently selected.
3. Newer Xcodes don’t include GCC anymore
Xcode 6 no longer includes GCC which is required for building some native Gem extensions for certain Rubygems. The fix here is to install Apple GCC via Homebrew, Macports, or some other package manager. You can also build directly from source if you want.
Exactly how to do all this is beyond the scope of this article. Hopefully now you’ve been alerted to some possible solutions that you haven’t already investigated. Armed with this knowledge I now send you off into the world to look up how to install Xcode’s command line tools, select a different version of command line tools, and install GCC on a Mac with Xcode 6.