Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cocoaPods pod install Permission denied

This is the short version:

When I run

pod install  

in an Xcode project I get

[!] Pod::Executable pull error: cannot open .git/FETCH_HEAD: Permission denied

If I run

sudo pod install 

I get no error, but my files installed are owned by root and can't compile and I have to chown those files to a normal user to use the Xcode compiler.

I am running Lion OSX.

I installed cocoaPods using

sudo gem install cocoaPods 

I had to use sudo because without it I got

ERROR: While executing gem ... (Gem::FilePermissionError)

You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.

so now I have a root installed version of cocoaPods that downloads root owned Xcode libraries.

Is sudo installation of cocoaPods the wrong way or normal way?

If normal, is there a way to fix the pod install problem?

like image 468
godzilla Avatar asked Apr 17 '13 00:04

godzilla


People also ask

Should I install CocoaPods with GEM or homebrew?

I would suggest you install CocoaPods using brew . It's a little cleaner option and you can update it easier. The cocoapods cask is for CocoaPads App and the formula is for the CLI only version. Save this answer.


1 Answers

I solved this problem by running the following command:

sudo chown -R $USER ~/Library/Caches/CocoaPods 

and

sudo chown -R $USER ~/.cocoapods 

Please replace username and groupname with your Mac login username/groupname.

like image 163
jianpx Avatar answered Nov 11 '22 16:11

jianpx