14

When I run

$ gem install cocoapods 

I get

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

I've read this post cocoaPods pod install Permission denied but the answer there doesn't say whether it is correct to run sudo on your gem install (despite being asked in the Question - i.e. Is sudo installation of cocoaPods the wrong way or normal way? ).

4 Answers 4

14

It seems you are not using any package manager. Since, you don't have write permission to this directory, there is nothing wrong in using sudo for gem install.

However, I prefer changing ownership of that directory, so that I don't have to use sudo every time.
i.e. sudo chown -R [login name] /Library/Ruby/Gems/2.0.0

and ensure that I have write permission. sudo chmod -R u+w /Library/Ruby/Gems/2.0.0

Consider using rvm (ruby version manager) or rbenv

Sign up to request clarification or add additional context in comments.

3 Comments

I am using rvm. Why does it seem like I'm not?
Well, in that case, I would recommend using rvmsudo instead of just sudo. Check out this link for further details: rvm.io/integration/sudo
you can use sudo chown -R $USER /Library/Ruby/Gems/2.0.0 for direct copy/paste
13
 sudo gem install cocoapods 

works for me

1 Comment

You shouldn't use sudo for that. It's better to fix the underlying problem, see other accepted answer.
3

This is the solution when you are receiving the "Operation not permitted" error.

$ mkdir -p $HOME/Software/ruby $ export GEM_HOME=$HOME/Software/ruby $ gem install cocoapods [...] 

Comments

-1

You need to 'update Gems'. Open terminal, then do this

sudo gem update 

That's enough.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.