Cannot install cocoa pods after uninstalling, results in error
Asked Answered
F

5

121

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?

Frambesia answered 12/6, 2015 at 21:59 Comment(2)
I'm using an administrator account, how would I go about fixing permissions?Frambesia
'pod' doesn't exist in /usr/binFrambesia
C
424

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.

Clodhopping answered 15/6, 2015 at 17:10 Comment(6)
Thanks! The combined command (including the sudo reboot) failed for me and froze the computer on several different attempts. Hard resetting did not keep the nvram settings. I had to run the first command until the semi-colon, and then restart from Apple menu. Then, cocoapods could install. Thank you!!!Neuburger
in El Capitan GM the first install (sudo gem install cocoapods -V) didn't work, the second one did though!Heptarchy
what's the downside of disabling rootless?Dimissory
The downside is SecurityClodhopping
I had this issue after updating my Mac Mini from Yosemite to El Capitan.Penetrance
How to choose a older version in this condition?Capers
S
162

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

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

Any caveats?

Sequel answered 3/8, 2015 at 9:28 Comment(2)
This is a much better solution than mine.Clodhopping
how long it will take to install.it is taking more time.Hakim
S
4

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.

Snaggy answered 12/8, 2015 at 16:23 Comment(0)
M
1

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"
Marjana answered 2/3, 2019 at 12:31 Comment(0)
C
-1

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

Castleberry answered 1/5, 2016 at 23:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.