CocoPods pod install Permission denied

This is the short version:

When i started

pod install 

in xcode project i get

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

If I run

 sudo pod install 

I am not getting errors, but my installed files are owned by root and cannot compile, and I have to chown these files to regular users using 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 do not have write permissions to the / Library / Ruby / Gems / 1.8 directory.

so now I have the root version of cocoaPods installed that loads the Xcode root libraries.

Is sudo installing cocoaPods the wrong way or the usual way?

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

+51
cocoapods rubygems
Apr 17 '13 at 0:13
source share
9 answers

I solved this problem by running the following command:

 sudo chown -R username:groupname ~/Library/Caches/CocoaPods 

and

 sudo chown -R username:groupname ~/.cocoapods 

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

+96
Jul 09 '13 at 7:52
source share

I used only (where username is your Mac login)

 sudo chown -R username ~/Library/Caches/CocoaPods 

and

 sudo chown -R username ~/.cocoapods 

when i tried with the groupname parameter i got

 chown: username.groupname: illegal user name 

Of course I used my own username and group name :)

+20
Sep 05 '13 at 13:43 on
source share

Removing directories working for me:

 sudo rm -R ~/Library/Caches/CocoaPods sudo rm -R ~/.cocoapods/repos 

If some other problems still exist.

Delete the Pods directory and the podFile.lock file.

Cocoapods just adds directories again.

+11
Jan 31 '14 at 10:09
source share

The problem is installing Mac OS X by default Ruby. The Ruby / Gems installation is owned by root at the location you specify.

This is normal behavior unless you install the Ruby manager. I would recommend rbenv , but RVM is popular as well.

They installed your Ruby installation in the $HOME folder. Thus, your user owns Ruby and gem executables.

+4
Apr 17 '13 at 0:34
source share

With all the errors I received while installing CocoaPods in some of my projects, I finally managed to find a template with it. There he is:

  • Access to the project folder from the terminal:

     $ cd /Users/username/Downloads/MessagesTableViewController-master 
  • Create a podfile:

     $ touch podfile $ open -e podfile 
  • After creating the podfile, access it through the Finder and edit it in any text editor other than TextEdit, because TextEdit sometimes messed up the apostrophes in the pod file. I used textWrangler. Write the following in the pod file: (Note that these dependencies are for projects supporting iOS version 6.0 and higher)

     platform :ios, '6.0' pod 'AFNetworking' 
  • Save the file and close it.

  • Return to the terminal and see the version of your port:

     $ pod --version 

    Depending on the version of your module, if an update is required, run the following command:

     $ sudo gem update 
  • After the update is complete or indicated that it has already been updated, you must install cocoapods:

     $ sudo gem install cocoapods 
  • And at the very end, just run the following commands:

     $ sudo pod setup $ sudo pod install 

And Viola! Done. In the project folder, you will see a folder named Pods, and the dependency you specified in the pod file will be displayed in the Pods folder as a subfolder.

Happy coding :)

+4
Mar 12 '14 at 23:17
source share

Fast, easy, hacker solution:

 sudo chmod -R 777 ~/.cocoapods sudo chmod -R 777 ~/Library/Caches/CocoaPods 
0
May 03 '14 at 1:15
source share

Answering the original question:

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

When I do pod install , I get:

 Analyzing dependencies CocoaPods 0.36.0.beta.1 is available. To update use: `sudo gem install cocoapods --pre` 

so I assume sudo is ok.

0
Jan 02 '15 at 11:57
source share

This is a known issue. There's more on the CocoaPods official website .

0
Sep 22 '15 at 17:56
source share

I solved this by installing the latest version of Ruby. Instructions are here: https://gorails.com/setup/osx/10.12-sierra Then I was able to successfully launch update sudo gem sudo gem install cocoapods

0
Oct 05 '17 at 20:07 on
source share



All Articles