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).
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 .
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.
Try this, It worked for me
sudo gem install cocoapods -n /usr/local/bin
This answer has information on why /usr/bin
is protected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With