Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You don't have write permissions for the /usr/bin directory. while installing Cocoapods

I'm trying to install Cocoapods using the following command on my Mac:

sudo gem install cocoapods 

But I'm getting the following error:

ERROR:  While executing gem ... (Gem::FilePermissionError)     You don't have write permissions for the /usr/bin directory. 

Really doesn't make sense as I'm doing is via sudo as the root user. Any help will be appreciated!

I'm using gem version 2.7.7 (latest as of today).

like image 424
Dimitri Avatar asked May 19 '18 07:05

Dimitri


People also ask

Should I install CocoaPods with GEM or homebrew?

If you try to install a gem through pre-installed Ruby, you've to use sudo by default witch is not a good practice. Another option is to install CocoaPods in your user-level directory by following instructions available on the Sudo-less installation section. I would suggest you install CocoaPods using brew .

How do I install dependency on CocoaPods?

After you have initially installed CocoaPods into your project, you can add new dependencies (or remove unused ones) by editing the Podfile. Then simply run pod install again.


1 Answers

Try this, It worked for me

sudo gem install cocoapods -n /usr/local/bin 

This answer has information on why /usr/bin is protected.

like image 175
Joe Avatar answered Sep 29 '22 08:09

Joe