Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove Permission denied @ rb_sysopen - Gem install error?

Tags:

I am trying to install create a new app in Ruby on Rails and I cannot get passed this error:

$ gem install pg 

ERROR: While executing gem ... (Errno::EACCES) Permission denied @ rb_sysopen - /Users/stormyramsey/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/pg-0.21.0/.gemtest

like image 430
Stormy Ramsey Avatar asked Jun 27 '17 01:06

Stormy Ramsey


2 Answers

Its a permissions issue. You could fix it with this:

sudo chown -R $(whoami) /Library/Ruby/Gems/* 

or possibly in your case

sudo chown -R $(whoami) /Users/stormyramsey/.rbenv/versions/2.3.2/lib/ruby/gems/* 

What does this do:

This is telling the system to change the files to change the ownership to the current user. Something must have gotten messed up when something got installed. Usually this is because there are multiple accounts or users are using sudo to install when they should not always have to.

like image 181
Bryan Norden Avatar answered Sep 21 '22 00:09

Bryan Norden


It's likely there's a permissions problem somewhere along the .rbenv path. You might try turning on write privileges for your user with:

$ chmod -R +w ~/.rbenv 

That will recursively (-R) change the file mode (chmod) to write permission (+w) for all files and directories under your user's .rbenv path. There's no particular reason for not having files set to write.

like image 35
Kathryn Avatar answered Sep 20 '22 00:09

Kathryn