-1

I'm trying to download rails and have gone through every solution I can find. I have redownloaded Xcode (7.0 beta) and have installed command line tools separately, including running: xcode-select --install which seems to work for most people with the same problem. I'm think I may have corrupted C header files.

checking if the C compiler accepts ... *** extconf.rb failed ***

Would massively appreciate any help!

The full error code:

XXX-MacBook-Pro-2:~ XXX$ gem install rails
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

/Users/XXX/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150923-10275-18xpyzg.rb 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=/Users/XXX/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
--help
--clean
/Users/XXX/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/XXX/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/mkmf.rb:571:in `block in try_compile'
from /Users/XXX/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/mkmf.rb:522:in `with_werror'
from /Users/XXX/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/mkmf.rb:571:in `try_compile'
from extconf.rb:80:in `nokogiri_try_compile'
from extconf.rb:87:in `block in add_cflags'
from /Users/XXX/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/mkmf.rb:619:in `with_cflags'
from extconf.rb:86:in `add_cflags'
from extconf.rb:337:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/XXX/.rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/XXX/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.6.2/gem_make.out
Schwern
  • 153,029
  • 25
  • 195
  • 336
  • 1
    http://stackoverflow.com/questions/29317640/gem-install-rails-fails-on-ubuntu – SSpoke Sep 23 '15 at 01:54
  • Homebrew or one of the other OS X package managers takes most of the pain out of installing open source on Mac. – Gene Sep 23 '15 at 01:56
  • 1
    Can you add contents of `mkmf.log`? Also are you running `homebrew`? If so, what's the output of `brew list | grep libxml2`? – Gavin Miller Sep 23 '15 at 01:57
  • Is it `nokogiri` that failed? That gem has [special problems on OS X](http://stackoverflow.com/questions/19643153/error-to-install-nokogiri-on-osx-10-9-maverick). – Schwern Sep 23 '15 at 02:00
  • *"Check the mkmf.log file for more details."* – Iskar Jarak Sep 23 '15 at 02:03

4 Answers4

1

I was facing the same issue from past two weeks while trying to run a rails 3 version application.

The issue is that your rvm/rbenv is not using the C compiler.

Use this command for rvm to take compatible C compiler

CC=gcc rvm install-version

So if you are using Ruby 1.9.3, use it this way

CC=gcc rvm install-1.9.3

Use this command every time you are not able to bundle install or anything. This thing is working on El Capitan, rails 3.2.16, ruby 1.9.3, mysql 5.7 Hopefully, It will resolve the issue.

0

I believe this line indicates it's not a Rails problem but a problem with nokogiri.

Gem files will remain installed in /Users/XXX/.rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.6.2 for inspection.

nokogiri has problems installing on OS X. Try one of the solutions here.

Community
  • 1
  • 1
Schwern
  • 153,029
  • 25
  • 195
  • 336
0

It does seem like it's a nokogiri problem as gem install nokogiri runs up errors (and this is in line with all the stack exchange answers I've come across - I've tried about 20 of them and spent a few hours on this).

Where do I find the mkmf.log file?

These are what I have in gem:

activesupport-4.2.4         nokogiri-1.6.6.2
i18n-0.7.0              nokogiri-1.6.7.rc3
mini_portile-0.5.3          rails-deprecated_sanitizer-1.0.3
mini_portile-0.6.2          thread_safe-0.3.5
mini_portile-0.7.0.rc4          tree-0.2.1
minitest-5.8.1              tzinfo-1.2.2
nokogiri-1.6.1
0

Try the following on Ubuntu 14.04:

sudo apt-get install libgmp-dev

After that you should be able to proceed with bundle install.

Can Selcik
  • 23
  • 2
  • 4