1

I always failed to install rails on my new Air with OSX 10.8.4, even I succeed installed ruby2, Command Line Tool of XCode, it still prompts some error when I try to install rails.

I found lots solutions from the Internet, but they all don't work on my issue, I'm completely confused, doesn't any can help me? I'll really appreciate!!!


 localhost:myapp zerocool$ ruby -v ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0] localhost:myapp zerocool$ 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/zerocool/.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/zerocool/.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/zerocool/.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/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0' from /Users/zerocool/.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/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12 for inspection. Results logged to /Users/zerocool/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12/ext/gem_make.out 
10
  • 2
    it looks like you have rvm installed. is there a particular reason you're doing sudo gem install instead of gem install? Commented Aug 11, 2013 at 3:53
  • What are the contents of mkmf.log? Commented Aug 11, 2013 at 3:55
  • I use sudo gem install 'cause if I just use gem install, it will prompt there's some permission issue. Commented Aug 11, 2013 at 4:41
  • I don't know where the mkmf.log is, I use whereis command cannot find it, could you please give the path? Thanks! Commented Aug 11, 2013 at 4:44
  • Check this thread: stackoverflow.com/questions/11802918/… It discusses a problem very similar to yours Commented Aug 11, 2013 at 4:49

4 Answers 4

2

I ran into this issue today and it seems that my download of ruby-2.0.0 did not work properly. I would recommend trying rvm reinstall 2.0.0 followed by gem install rails.

Sign up to request clarification or add additional context in comments.

1 Comment

I had to rvm get stable, followed by rvm reinstall 2.0.0, but this did the trick for me. Thanks.
1

Finally, I got the solution! Run rvm implode,and use rm to delete /etc/rvmrc and ~/.rmvrc, restart your mac, and you can use gem install rails to install rails successfully.

1 Comment

Be careful with this - rvm implode removes all rvm gemsets from your system, so if you already have projects running on RVM this will reset them.
1

First I installed gcc via homebrew:

installing gcc on mavericks using brew

brew tap homebrew/dupes brew install apple-gcc42

Then I symlinked the newly installed apple-gcc42 into my /usr/bin folder

cd /usr/bin

sudo mv gcc gcc_mavs sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 gcc

Credits: https://coderwall.com/p/lqpp8w

1 Comment

I've just been having the same issue on El Capitan. For anyone else coming across this on El Capitan, try following these instructions, but skip sudo mv gcc gcc_mavs.
0

I had this same error when running against ruby-2.0.0-p195, but updating to ruby-2.0.0-p247 (the current RVM default for 2.0.0) fixed it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.