Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to install Rails extconf.rb failed

I'm new to Ruby on Rails, and I'm getting the below error when I'm installing it.

Please note, I have installed the latest Xcode and installed command line tools, and I'm using OSX 10.8.4. I've installed Ruby 2.0.0 as well.

-bash-3.2$ sudo gem install rails
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
ERROR: Failed to build gem native extension.

/Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
*** 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/WillieTran/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
--with-atomic_reference-dir
--without-atomic_reference-dir
--with-atomic_reference-include
--without-atomic_reference-include=${atomic_reference-dir}/include
--with-atomic_reference-lib
--without-atomic_reference-lib=${atomic_reference-dir}/
/Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/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 /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
from /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:817:in `try_run'
from extconf.rb:24:in `<main>'


Gem files will remain installed in /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12 for inspection.
Results logged to /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12/ext/gem_make.out
like image 384
Willie Tran Avatar asked Dec 01 '22 20:12

Willie Tran


2 Answers

I had similar problem and it gets solved by installing command line tools:

xcode-select --install
like image 74
Hua2308 Avatar answered Dec 06 '22 18:12

Hua2308


The symlinking did not solve the problem for me. I uninstalled my ruby that I previously had installed using rvm by typing rvm uninstall ruby-2.0.0 and then I typed rvm requirements. This command found that I needed a few other things, such as gcc46. It's strange that the gcc compiler was needed, even though I had installed the xcode command line tools, and gcc was most definitely installed on my system.

So, if none of the usual methods are working, give rvm requirements a shot!

like image 41
Danny Avatar answered Dec 06 '22 18:12

Danny