3

I am trying to install the ruby gem "yajl ruby". I'm running Mac OS 10.7.4 and Ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]. When I run:

sudo gem install yajl-ruby

I get the following output:

Building native extensions.  This could take a while...
ERROR:  Error installing yajl-ruby:
    ERROR: Failed to build gem native extension.

        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
creating Makefile

make
gcc -I. -    I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0     -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.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  -Wall -funroll-loops  -c yajl.c
make: gcc: No such file or directory
make: *** [yajl.o] Error 1


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/yajl-ruby-1.1.0 for     inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/yajl-ruby-1.1.0/ext/yajl/gem_make.out

What do I need to do in order to make the install work?

histelheim
  • 4,938
  • 6
  • 33
  • 63

3 Answers3

1

Try this:

$ sudo ln -s /usr/bin/llvm-gcc /usr/bin/gcc-4.2

lun
  • 11
  • 3
0

It's a bit roundabout, but have you considered using RVM to manage your Ruby versions? As this you're working on an OS X box, I'm assuming it's your dev machine and so having a system-wide gem probably isn't as big a deal. RVM changes the paths for installing gems to be relative to the Ruby version in use and, as the paths are local to your user directory, you don't need to use sudo and thus avoid potential permission errors which is what I suspect is happening here.

I say I suspect it's a permission error because the missing file suggests something wasn't written to where it's expected to be. It's just a shot in the dark, though. Alternatively, you could try actually su'ing to root and doing the gem install there, but that's ugly.

mjbraun
  • 117
  • 5
0

I had a similar error installing yajl-ruby.

The error was that /Developer/usr/bin wasn't available. Doing an "ln -s /Applications/Xcode.app/Contents/Developer/usr/ /Developer/usr" fixed the error.

Here is the specific error I was seeing:

    gem install yajl-ruby
Building native extensions.  This could take a while...
ERROR:  Error installing yajl-ruby:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
creating Makefile

make
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.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  -Wall -funroll-loops  -c yajl.c
sh: /Developer/usr/bin/xcodebuild: No such file or directory
/Developer/usr/bin/xcodebuild fails with 32512 - Unknown error: 32512
make: *** [yajl.o] Error 69


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/yajl-ruby-1.1.0 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/yajl-ruby-1.1.0/ext/yajl/gem_make.out
Joey Lesh
  • 366
  • 2
  • 5