Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails install ERROR: Failed to build gem native extension

I am trying to install rails on my mac, but every time I type sudo gem install rails into the command line, I get the following error message. I have been stuck for a while, hope you can help.

    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/2.0/usr/bin/ruby extconf.rb
    mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h


    Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.14 for inspection       
    Results logged to /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.14/ext/gem_make.out
like image 931
user1809336 Avatar asked Mar 22 '23 14:03

user1809336


2 Answers

If you are trying to install Rails 4.0, it needs RubyGems 2.0.3, so you have to update your system by using following command

gem update --system 2.0.3

and then continue with your installation.

Hope it helped

like image 122
Nikhil Nanjappa Avatar answered Mar 31 '23 16:03

Nikhil Nanjappa


I would just use rvm. It should work like a charm. Or you could dig around and see if you can find that ruby.h file its talking about. But I personally think the latter would be a pain in the ass.

like image 32
stanley Avatar answered Mar 31 '23 16:03

stanley