-2

I am trying to install rails following the instructions on this site, but I get an error when I key in the following command:

gem install rails -v 4.2.4

The error is

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

I have read the related post on SO here, but am unsure of what exactly to do to rectify my situation...

Community
  • 1
  • 1
Roy
  • 277
  • 1
  • 5
  • 17
  • 1
    You problem has already been addressed in the [question](http://stackoverflow.com/questions/14607193/installing-gem-or-updating-rubygems-fails-with-permissions-error) you referred. – usmanali Sep 18 '15 at 06:43
  • yes, but it has been addressed, but I am confused on what exactly to do like I said in my post – Roy Sep 18 '15 at 06:44
  • How exactly did you install ruby? – usmanali Sep 18 '15 at 06:44
  • based on the instructions on the site I posted above...pasting the exact content here....brew install rbenv ruby-build # Add rbenv to bash so that it loads every time you open a terminal echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile source ~/.bash_profile # Install Ruby rbenv install 2.2.3 rbenv global 2.2.3 ruby -v – Roy Sep 18 '15 at 06:46
  • can you show the output of `which ruby`? – usmanali Sep 18 '15 at 06:47
  • What I get is /usr/bin/ruby – Roy Sep 18 '15 at 07:25
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/89994/discussion-between-usmanali-and-roy). – usmanali Sep 18 '15 at 07:27

1 Answers1

0

Read the question again and its solution (the question you reffered in the description).

I will try to explain the reason why its giving you errors.

/Library/Ruby/Gems/2.0.0

In this directory your operating system has a certain version of Ruby installed. The system might require it for some purposes so normal users are not allowed to modify this directory. If you do it you might end up breaking up something without knowing.

Does this means you can not install it on your machine? No, you can but not in this directory. Again in the question op gives the option of looking into :

"Instead, I'll strongly suggest you look into using either rbenv or RVM to manage a separate Ruby, "

one of these should do it for you.

You might want to try this with vagrant. I found it pretty convenient to test new development environment without trying to break anything on my system. Here is a link about trying rails in vagrant:

https://gorails.com/guides/using-vagrant-for-rails-development

Deepak
  • 1,503
  • 3
  • 22
  • 45
  • thanks for explaining, I am indeed using rbenv. So why do I still have issues? Basically I am following this site's instructions closely https://gorails.com/setup/osx/10.10-yosemite – Roy Sep 18 '15 at 07:50
  • @Roy have your tried the command with sudo? for eg "sudo gem install rails -v 4.2.4". This will ask you for a password which should be your login password. This should give you permissions to overwrite the directory. you are trying to do – Deepak Sep 19 '15 at 03:31
  • @Roy read more about sudo here if you have not tried this before https://support.apple.com/en-us/HT202035 – Deepak Sep 19 '15 at 03:32