Trying to install a gem (gem install mygem
) or update RubyGems (gem update --system
) fails with this error:
ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Anyone having idea how to solve this?
The reason of the error is because you are not logged in as the root user on terminal.
If you already have root use enable on your mac in terminal type
If you dont have root user, you need to enable it using the following steps
More at the same on http://support.apple.com/kb/ht1528
Atleast it works for me after getting stuck for couple of hours.
Work for me:
Try nathanwhy's answer before using my original answer below. His recommendation of
--user-install
should accomplish the same purpose without having to muck with your.bash_profile
or determine your ruby version.If you are not concerned about a specific ruby version, you can skip the heavy-lift ruby environment manager options, and just add these lines to
~/.bash_profile
:The path is stolen from the original output of
gem env
:No
sudo
ing is required, and you can use the already-installed ruby, courtesy of Apple.I used this and worked.
$ sudo chown myuser /var/lib/gems
Try adding
--user-install
instead of usingsudo
: