13

I'm trying to put a google sign in for my ios app and to do that I need CocoaPods. But when installing it like there own website on terminal I get this:

$ sudo gem install cocoapods

[Password: (*Put in my admin password for my macbook*)
ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.

This is being done on a Macbook Air running High Sierra 10.13.2 (Don't know if you need that info but I've never done anything with cocoapods or ruby before)

I also tried following this link and followed the awnser and installed RVM, or at least I think I did. I just put this in:

ruby -e "$(curl -fsSL 
https://raw.githubusercontent.com/Homebrew/install/master/install)"

Well I tried installing CocoaPods after that but still got the same thing.

1 Answer 1

40

You might try the following command

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


The problem is that gem install was trying to use /usr/bin for installing the binaries, which shouldn't be touched for the System Integrity Protection. Since:

A centerpiece is the protection of system-owned files and directories against modifications by processes without a specific "entitlement", even when executed by the root user or a user with root privileges (sudo)

Sudo is without any power in this situation.

Hence the solution uses -n, from gem help install it says:

-n, --bindir DIR Directory where binary files are located

in this way you will be able to move the binaries in a more comfortable destination: /usr/local/bin which stands for programs that a normal user may run.

3
  • Looks good. Just to make sure that everything is right, is this what it's supposed to look like? : Successfully installed cocoapods-1.3.1 Parsing documentation for cocoapods-1.3.1 Done installing documentation for cocoapods after 3 seconds 1 gem installed It took only a couple of seconds and I heard it takes awhile. And if it is correct, thank you!
    – Adam Zyluk
    Commented Dec 29, 2017 at 2:11
  • This worked for me, i've run command sudo gem install cocoapods -n /usr/local/bin and installed Commented Mar 18, 2021 at 22:45
  • 1
    Saved me. Installing react native was failing on the cocoapod step. This fixed it. Thank you! Commented Nov 17, 2023 at 19:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.