Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing gem fails with permissions error [duplicate]

I updated my Mac OS to 10.9 Mavericks yesterday. My current Ruby version shows as

ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]

I got Rails installed on my machine and when I try to install gems I get the following message:

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

I am trying all this in my home directory. Any suggestions?

like image 205
Aniruddha Avatar asked Oct 25 '13 01:10

Aniruddha


People also ask

How do I install a new gem?

To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs. There are other sources of libraries though.


1 Answers

Use a Ruby version manager, like RVM or rbenv.

I can't speak for rbenv, but RVM prepends a Ruby version-specific bin to your PATH that you have access to, so you don't have to use sudo (which is how you could install gems in your current situation, but is highly discouraged).

rbenv similarly prepends to your $PATH, but it uses a shim.

like image 93
Stuart Nelson Avatar answered Oct 28 '22 05:10

Stuart Nelson