0

I have installed up-to-date command line tools, and followed steps on other threads with this subject. I know this seems like a duplicate, but I don't see any answers to my issue here:

Jacobs-MacBook-Pro:~ jacob$ sudo gem install rails
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
checking if the C compiler accepts ... *** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--help
--clean
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:549:in `block in try_compile'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:500:in `with_werror'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:549:in `try_compile'
from extconf.rb:80:in `nokogiri_try_compile'
from extconf.rb:87:in `block in add_cflags'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:597:in `with_cflags'
from extconf.rb:86:in `add_cflags'
from extconf.rb:336:in `<main>'


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.7.2/ext/nokogiri/gem_make.out
1
  1. First, check if you have Xcode installed
  2. Second, if you already have Xcode in your Mac, use this command:

    CC=gcc rvm install-version
    

Example

CC=gcc rvm install-1.9.3

Reason for this error in Mac OS is that your Ruby is not able to get the C header files

Hope, this works on all the Macbook's.

Its working on El Capitan, ruby 1.9.3, rails 3.2, mysql 5.7

  • That worked. When I went to install homebrew after, I got a message in terminal saying I hadn't agreed to the license terms in Xcode. I have had it for a while, but I've not opened it on this computer. I opened it, and agreed to the terms/conditions, then everything after that went smoothly with rails. I'm not sure if that is relevant information to anyone else reading this post, but it was a part of the problem with this process. – rbApostate May 24 '16 at 7:39
  • Also, I got this message after running the "CC=gcc...": "No binary rubies available for: osx/10.11/x86_64/ruby-2.0.0.p648. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies." Is that going to be a problem, or do I need to do something about that as well? – rbApostate May 24 '16 at 7:45
  • I don't think if that is going to be a problem for you. If it is let us know but "Agreeing to license terms in Xcode" was indeed a big thing. – Aditya Shukla May 24 '16 at 8:30
  • Kindly, tick the answer if it worked for you. – Aditya Shukla May 24 '16 at 8:45
  • I agreed to the terms, installed homebrew, and then I was able to install ruby without any further errors. Mission accomplished. – rbApostate May 24 '16 at 9:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .