I’m getting this when trying to install rails using: gen install rails
I barely have any idea what I’m doing :/ Trying to learn 🙂
ERROR: Error installing rails:
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/json-1.7.5 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
Thanks in advance!
I’ve tried following directions here (http://rubyonrails.org/download) and here (http://rubygems.org/pages/download).
I’m going to assume that you’re new to Ruby as well, just in case doing so can help others who need this answered. Please don’t take offense.
It looks like your installation of Ruby is out of date or broken. Mac OSX comes with a default Ruby installed, but I honestly have no idea if it’s complete or out of date because I always install my own.
Getting a Build Environment Ready
By default, MacOSX does not have the capacity to build C applications, which is what the “standard” ruby runtime is. So, you need to install a C building toolchain, which in many cases is GCC & friends.
Without XCode Installed
With XCode Installed
Once you’ve installed them, close any open terminal windows before proceeding to ensure that the build tools are in your path.
Installing Ruby
There are a few ways to get Ruby going on a new linux system, but the most widely recommended one is to use rvm.
RVM is a tool which helps install and manage different Ruby environments, so you can easily switch between them and upgrade (or downgrade for a specific project or issue). It’s found here (direct link to the installation instructions) You most likely want to do the first of the Quick guided installs, which will simply install it for your user. It’ll also install the latest stable version of ruby.
There is a GUI for installing RVM, called JewelleryBox. It’s fairly pretty and will notify you when there’s new versions.
Once the app itself is installed:
Installing Rails
Ruby’s almost ubiquitous means of fetching libraries, including Rails, is with rubygems and the
gemcommand. In this case,gem install railsshould get you started. Oh, and make sure you open a new terminal window after installing a new ruby, and check it’s installed withruby -v.Another nice thing
Bundler is a neat package manager built on top of rubygems. Install it with
gem install bundle(oh, and Rails will install it as a dependancy). Its got its docs at this link but for basic, raw rails, you shouldn’t need to do anything with it.Good Luck
Have a blast learning Rails, I hope you find it makes webapp development more fun for you ^_^