26

When executing gem install jekyll on OSX 10.8 with the standalone Command Line Tools package from Apple's Developer site installed (no Xcode), i run into the following error:

Building native extensions. This could take a while...

ERROR: Error installing jekyll:

ERROR: Failed to build gem native extension.

xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common   -c porter.c
xcrun: Error: failed to exec real xcrun. (No such file or directory)

gcc is installed:

$ which cc
/usr/bin/cc

the look-up path for xcrun is set:

xcode-select -print-path
/usr/bin

yet no matter which arguments i try, xcrun will always return

xcrun: Error: failed to exec real xcrun. (No such file or directory)

man xcrun reads "When xcrun is invoked with the name xcrun , the flags -log and -verbose are useful debugging aids. The flag -no-cache can be used to bypass cache lookup." but none of this seems to have any effect: the only output remains the above…

Solution: following Ned Deily's advice below, i've replaced xcrun with a shell script to simply call the given arguments:

#!/bin/bash
$@
Lukas Grebe
  • 1,844
  • 4
  • 16
  • 17
  • By "Command Line Tools installed", do you mean you only have the standalone `Command Line Tools` package installed from the Apple Developer site without installing `Xcode.app` or do you have Xcode.app installed and then installed its `Command Line Tools` component from the `Xcode.app` `Preferences` menu? – Ned Deily Oct 24 '12 at 01:09
  • The standalone package from Apple's Developer site. - I modified the question to make this more clear. Sorry about the confusion. – Lukas Grebe Oct 24 '12 at 01:14
  • It was easy enough to override my path: `export PATH=$HOME/local/bin:$PATH` to specify an override file of `~/local/bin/xcrun` to include the hack. I also had to run `sudo xcode-select -switch /usr/bin` to match the `-print-path`. – chrischris May 05 '13 at 08:07
  • Looks like the hack needs to be put in `/usr/bin/xcrun` not an `xcrun` override somewhere else in the `PATH`. – Erik Kaplun Oct 13 '13 at 16:37

4 Answers4

24

Unfortunately, at least the last time I played with it, I found you really can't use xcrun with just the standalone Command Line Tools package. It apparently wasn't designed for that use case; the standalone package is a fairly recent innovation with Xcode 4. If the product you are trying to install really depends on xcrun, you may need to install the full Xcode.app distribution to get around it. That, or modify the distribution's Makefile et al to not use xcrun. Or, possibly (untested), create some directories and/or symlinks to fake xcrun into thinking you have Xcode.app installed - a messy hack.

Ned Deily
  • 83,389
  • 16
  • 128
  • 151
  • 11
    What a dirty hack! I wonder when it'll come back to bite me: I replaced xcrun with a two line shell script: #!/bin/bash $@ – Lukas Grebe Oct 24 '12 at 01:43
  • 1
    Heh. Another thing: the standalone Command Line Tools does not provide SDKs like the full Xcode does. So if what you are building requires an SDK for an earlier OS level, you'll need the full Xcode install. – Ned Deily Oct 24 '12 at 01:46
  • 2
    Wow. That hack worked for me! It ain't pretty, but better than installing over a gig of crap I don't need. – Tom Rossi Feb 07 '13 at 17:12
18

Type in these commands on the console:

sudo xcode-select -switch /usr/bin
sudo mv /usr/bin/xcrun /usr/bin/xcrun-orig
sudo vim /usr/bin/xcrun

Enter the following into your dummy xcrun file:

#!/bin/sh
$@

Then make it executable:

sudo chmod 755 /usr/bin/xcrun
bitoiu
  • 6,893
  • 5
  • 38
  • 60
13

Even with Command Line Tools installed, your xcode-select is strange. It should be pointing into your XCode bundle, not /usr/bin:

$ xcode-select -print-path
/Applications/Xcode.app/Contents/Developer

Switch it to Xcode like this:

$ sudo xcode-select --switch /Applications/Xcode.app
Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • 5
    i just have the Command Line Tools installed, not Xcode. Setting the Path to /usr/bin made the most sense to me, as compilers reside there… switching thus results in an error: `xcode-select: Error: Path "/Applications/Xcode.app" is not a directory.` – Lukas Grebe Oct 24 '12 at 01:07
0

I was having trouble with brew install hg. It was choking on the output of xcodebuild -version.

It is a horrible hack, but I replaced /usr/bin/xcodebuild with a shell script that just echoed "4.3" and was able to install mecurial successfully.

deinspanjer
  • 495
  • 1
  • 7
  • 22