Installing theRubyRacer on OSX Lion w/Xcode 4.2.1
Struggled with this one quite a while last night. Turns out the solution is quite simple Everytime I would run
gem install therubyracer
I would get back an error like so:
Building native extensions. This could take a while...
ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.
/Users/marlon/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for main() in -lobjc... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/marlon/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-objclib
--without-objclib
/Users/marlon/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/marlon/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:435:in `try_link0'
from /Users/marlon/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:440:in `try_link'
from /Users/marlon/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:552:in `try_func'This is what the mkmf.log file had in it. Wasn’t much.
"/usr/bin/gcc-4.2 -o conftest -I/Users/marlon/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-darwin11.0.0 -I/Users/marlon/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/Users/marlon/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe conftest.c -L. -L/Users/marlon/.rvm/rubies/ruby-1.9.2-p290/lib -L. -L/usr/local/lib -lruby.1.9.1-static -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */Finally got the idea to try the command in the mkmf.log and figured out that I didn’t have a gcc-4.2 on my file system anywhere, only a ‘gcc’ that happend to be version 4.2.1. A quick symlink later and theRubyRacer compiled perfectly.
