Alex Rivera | Logout

Failed to build gem native extension

Asked 2012-03-04T04:24:00.380
21

End result is I'm trying to get Ruby on Rails installed on my OS 10.7.3, but having various issues.

Also, I have a freshly installed XCode 4.3 from the App Store.

When I fire up the terminal, and enter:

sudo gem install rails

and it writes out:

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

        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.6.5 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.6.5/ext/json/ext/parser/gem_make.out

In all of the fixes I'm finding says to install XCode, which I have and runs just fine. However, I did uninstall a previous version of XCode to install the latest version, so I'm wondering if there is any relation there.

EDIT 1: I've followed Jasdeep suggestion and installed RVM. But once i run:

sudo rvm install 1.9.3

I get the following:

Fetching yaml-0.1.4.tar.gz to /Users/xxx/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/xxx/.rvm/src
Configuring yaml in /Users/xxx/.rvm/src/yaml-0.1.4.
Error running ' ./configure --prefix="/Users/xxx/.rvm/usr"  ', please read /Users/xxx/.rvm/log/ruby-1.9.3-p0/yaml/configure.log
Compiling yaml in /Users/xxx/.rvm/src/yaml-0.1.4.
Error running 'make ', please read /Users/xxx/.rvm/log/ruby-1.9.3-p0/yaml/make.log


Database file /Users/xxx/.rvm/config/packages does not exist.

gcc-4.2: error trying to exec '/usr/bin/i686-apple-darwin11-gcc-4.2.1': execvp: No such file or directory
Installing Ruby from source to: /Users/xxx/.rvm/rubies/ruby-1.9.3-p0, this may take a while depending on your cpu(s)...

ruby-1.9.3-p0
Edit
Report

1 Answer

5

I already had Command-line tools installed (xCode as well)... and still had this (initial) error.

The problem was that xCode and the command line tools are no longer installing the gcc compiler. I don't know when they stopped shipping it, but I run mountain lion, and it's not here. So what eventually solved my problem was installing gcc from scratch (https://github.com/kennethreitz/osx-gcc-installer).

Keep Smiling :)

answered 2012-09-30T02:08:12.947

Your Answer