Cannot install cocoa pods after uninstalling, results in error

IosTerminalInstallationCocoapods

Ios Problem Overview


I removed cocoa pods because it claimed it had installed, but kept saying the command pod wasn't found afterward. When trying to reinstall cocoapods (sudo gem install cocoa pods -v) I get this error:

> ERROR: While executing gem ... (Errno::EPERM) > Operation not permitted - /usr/bin/pod

Screenshot for error

Any ideas?

Ios Solutions


Solution 1 - Ios

As it has been pointed out below by Ramesh Ramchandaran, this is a cleaner way of doing it, instead of getting around the Security features of OS X.

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

Original Answer

I'm assuming you're running OS X 10.11.

This is happening because Apple has enabled rootless on the new install.

If you type:

sudo nvram boot-args="rootless=0"; sudo reboot

in terminal.app, your computer will reboot with it disabled.

Once that is done, type:

sudo gem install cocoapods -V

the -V is for verbose and will spit out any errors if they happen.

Solution 2 - Ios

As rootless does not affect /usr/local/bin, the following succeeds:

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

Any caveats?

Solution 3 - Ios

Using home-brew or custom $GEM_HOME can help resolving the issue. I did clean installation of ruby with brew:

brew install ruby

Now the gem stuff seem to happen relative to my /usr/local/bin*, which is exactly what I needed.

Solution 4 - Ios

I recommend installing all your gems into your .gem folder in your home folder to avoid using sudo or a ruby version manager as other people suggest.

All you have to do is update your .bash_profile by adding these 2 lines. (Don‘t forget to restart your terminal after applying these changes)

export GEM_HOME=~/.gem
export PATH="$GEM_HOME/bin:$PATH"

Solution 5 - Ios

After updgrading from Yosemite to El Capitan ( 10.11.4), I kept getting the below error message while trying to 'reinstall' Cocoapods ( after trying out pretty much all the solutions under different Stackoverflow threads and the Cocoapods issue-page itself, for the same issue)

"Could not find a valid gem 'cocoapods' (>= 0) in any repository"

However, quit terminal, restarted system, created new Xcode project from the scratch and then when i did 'pod install', it worked.

Note: I was trying to use Alamofire and SwiftyJson cocoapods

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAdrian WackerView Question on Stackoverflow
Solution 1 - IosKyle BrowningView Answer on Stackoverflow
Solution 2 - IosRajesh RamachandranView Answer on Stackoverflow
Solution 3 - IosDrewView Answer on Stackoverflow
Solution 4 - IosPatrickDotStarView Answer on Stackoverflow
Solution 5 - IosNaishtaView Answer on Stackoverflow