23

Not sure what happened but when I upgraded to Mavericks it says that Rails it not install. I executed the following command:

rails --version

And it said "Rails is not currently installed and run sudo gem install rails".

I run sudo gem install rails and get the following:

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/json-1.8.1 for inspection.

UPDATE:

I ran the command gcc --version and got the following:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
john doe
  • 9,220
  • 23
  • 91
  • 167

4 Answers4

60

You need to install the Command Line Developer Tools. Just open Terminal and type up a command that requires it -- for instance, git, gcc or make. Or use the following command:

$ xcode-select --install

You'll see an alert like this:

enter image description here

Just click Install and that's it. As of OS X 10.9, there's no longer need to install Xcode for Ruby development.

Credit for the steps and picture goes to Daniel Kehoe in his latest guide: http://railsapps.github.io/installrubyonrails-mac.html

Marcelo De Polli
  • 28,123
  • 4
  • 37
  • 47
  • It does not give me pop up! It seems like I already have command line tools installed. – john doe Oct 25 '13 at 03:54
  • Try this command (also from the linked guide): `xcode-select -p` and also make sure you do have gcc installed by doing a `gcc --version`. – Marcelo De Polli Oct 25 '13 at 03:55
  • Try `xcode-select --install` and report what you get, please. – Marcelo De Polli Oct 25 '13 at 14:26
  • Okay after running xcode-select --install the popup opened and then I installed the command line tools. They are now installed! What next? – john doe Oct 25 '13 at 14:38
  • 1
    If I run sudo gem install rails it throws the same old error. – john doe Oct 25 '13 at 14:38
  • 1
    It doesn't work always, I've been experiencing so many issues after installing Maverick and the only solution has been cleaning everything and reinstall nearly everything, not only xcode, also every single library with macports – Maximiliano Rios Oct 29 '13 at 15:19
  • This does not work anymore. It simply throws an errord "software not found on server" – Eastern Monk Jun 04 '14 at 08:05
  • Also make sure you have XCode installed and components set up. For me, all I had to do was open XCode, and click on Accept for terms & conditions screen, and then re-running the gem install worked for me. – James Oct 08 '14 at 19:38
15

I had the same problem which I have now been able to solve.

The problem for me was that I had updated to the latest version of Xcode through the appstore but hadn't actually opened the application to complete the install. So here's what solved it for me:

  • Updated Xcode
  • Opened Xcode application
  • Accepted license agreement
  • Installed rails

Hope it works for you too.

PedroC88
  • 3,708
  • 7
  • 43
  • 77
  • This saved me! Thank you. Ended up here after updating to Yosemite. Ran my grunt build operation and a compass task failed with the following error: "Warning: Couldn't find the `compass` binary. Make sure it's installed and in your $PATH" – mogkav Jul 03 '15 at 12:10
  • ... Turns out that both Compass and Ruby must be installed correctly for grunt use. I went through https://github.com/gruntjs/grunt-contrib-compass/issues/66 to realise that Ruby and Compass versions needed to be updated and the gem install for compass was failing due to the path pointing to the incorrect version of Ruby. The reason for this is now clear due to this answer. Hope this saves time for someone else – mogkav Jul 03 '15 at 12:20
0

It wasn't working for me even when I reinstalled xcode and the command line tools for mavericks.

But after that, I just did a bundle update and, for some reason, it worked.

Bernardo
  • 519
  • 5
  • 16
0

I think I had the same issues. I updated the xcode and open xcode to accept licence aggrement. Then it worked fine as far as I can remember.

Aung
  • 74
  • 3