1
votes

I have been trying to install rails on my Macbook Air running OSX 10.9, but I keep running into errors.

When I type

$ gem -v

I get

2.0.3

and

$ rails -v

yields

Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.

When I type

$ gem install rails

I get

Fetching: i18n-0.6.9.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

So I type

$ sudo gem install rails

I put in my password and I get

Fetching: i18n-0.6.9.gem (100%)
Successfully installed i18n-0.6.9
Fetching: multi_json-1.8.2.gem (100%)
Successfully installed multi_json-1.8.2
Fetching: tzinfo-0.3.38.gem (100%)
Successfully installed tzinfo-0.3.38
Fetching: minitest-4.7.5.gem (100%)
Successfully installed minitest-4.7.5
Fetching: atomic-1.1.14.gem (100%)
Building native extensions. This could take a while...
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

and then I don't know what to do...

2
I suggest you install and use a ruby version manager, such as RVM, RBenv, or chruby, you'll run into less problems that with the bundled ruby in mac - Intrepidd

2 Answers

3
votes

I had this same problem on my MacBook Pro. You'll want to use a ruby version manager.

The reason a ruby manager will solve this problem is because the tool is installed into a path that is write-accessible to you — thus you will not get permission denied errors when installing.

  1. If you haven't already, you'll need to install homebrew: http://brew.sh/
  2. then install either:

    brew install rbenv.
    

    or

    brew install rvm
    

Personally, I use rbenv, but either works well under OS X.

After you have either rvm or rbenv installed and working, install your gem as usual.

1
votes

I followed the steps in the blog post below and I finally got rails working on my 2012 MacBook Air running Maverick(10.9.4).
http://www.createdbypete.com/articles/ruby-on-rails-development-setup-for-mac-osx/
Though probably overkill, I reloaded Terminal after I entered each line.

Now when I type:

$gem -v

I get

2.0.3

and if I type

$ruby -v

I get

ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]

And finally, when I type

$rails -v

I get

Rails 4.1.4

:)