Rubygems do not install on OS X Lion
Solution 1
I had to install the Command Line Tools in the latest Xcode-Version (4.3.1) and
sudo gem install rails
worked like a charm.
To install Command Line Tools, go to Xcode Preferences > Downloads or use the following command in terminal (thx @Purell):
xcode-select --install
Solution 2
I'm using Mavericks and Ruby 2.0.0 and I also got this error (mkmf.rb can't find header files) when installing gems. I solved this issue by creating some symbolic links in Terminal.
#First install developer tools again:
xcode-select --install
#Create symbolic link to Ruby include (updated for 10.9)
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include
#Create symbolic link to config.h (updated for 10.9)
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/2.0/Headers/ruby/config.h /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/config.h
Solution 3
I faced same problem while trying to install rails on my Lion. This is how i could solve it.
Install rvm
$ curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
Install osx-gcc-installer
https://github.com/kennethreitz/osx-gcc-installer
Installed new version of ruby
rvm install 1.9.3
Typed to following command to show the requirements
rvm requirements
To use an RVM installed Ruby as default, instead of the system ruby:
rvm system ; rvm gemset export system.gems ; rvm 1.9.3 ; rvm gemset import system.gems # migrate your gems
rvm alias create default 1.9.3
Installed rails:
sudo gem install rails
My Mac is now read for rails!! YAY!!
Solution 4
Not a direct solution to your problem, but I'd suggest using rvm to install fresh rubies and gems. That should take care of it.
Solution 5
While installing Rails I had the error :
can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
As i had already Xcode installed, I had just to install Command Line Tools to resolve this problem
Related videos on Youtube
d135-1r43
Updated on February 25, 2020Comments
-
d135-1r43 about 4 years
I used to have no problems at all with ruby, gems and all related stuff. But after installing X Code Developer Tools and upgrading to Lion the gems do not install.
I get the following error for every gem. This is the message for sqlite as an example:
Building native extensions. This could take a while... ERROR: Error installing sqlite3: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/sqlite3-1.3.4 for inspection. Results logged to /Library/Ruby/Gems/1.8/gems/sqlite3-1.3.4/ext/sqlite3/gem_make.out
What went wrong? How to fix it?
-
robustus over 12 yearsYou open up a Terminalwindow, choose your favorite Editor, and edit your .bashrc (usually in the path /Users/<Your Username>/.bashrc)
-
d135-1r43 over 12 yearsI know how to do that. I just do not know which path I should add there.
-
robustus over 12 yearsOh sorry i misunderstood: I'd suggest: /System/Library/Frameworks/Ruby.framework/Versions/1.8/
-
mattandrews over 11 yearsYep. To install Command Line Tools, go to XCode Preferences > Downloads.
-
Don Question over 11 yearsWelcom to SO. If i read the OP's question correct, he stateds he has XCode installed.
-
Purrell over 10 yearsSo apparently if you have OSX 10.9 Mavericks and Xcode 5.0, commandline tools doesn't (always?) show up in Preferences-->Downloads. But you can install it with "xcode-select --install"
-
emispowder over 10 yearsUpgrading to Mavericks seemed to have uninstalled developer tools. Running the first command from David fixes this issue for me. No need to symlink.