cocoaPods pod install Permission denied

為{幸葍}努か 提交于 2019-11-27 17:17:27
jianpx

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 login username/groupname.

André Herculano

I only used (where username is your Mac login username)

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 groupname :)

Martijn Mellens

Removing the directories worked for me:

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

If some other problems still exist.

Remove the Pods directory and the podFile.lock file.

Cocoapods just adds the directories again.

Mohsin Khubaib Ahmed

With all the errors that I got while installing CocoaPods in some of my projects, I've finally succeeded in finding a pattern with it. Here it is:

  1. Access your project folder from the terminal:

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

    $ touch podfile
    $ open -e podfile
    
  3. After the podfile is created, access it via the Finder and edit it in any other text editor except TextEdit because TextEdit sometimes messes up with apostrophes in the pod file. I used textWrangler. Write the following in the pod file; (Note these dependencies are for projects that support iOS version 6.0 and above)

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

  5. Go back to the terminal and see your pod version:

    $ pod --version
    

    Depending on your pod version, if an update is required, run this command:

    $ sudo gem update
    
  6. After the update completes, or it states that it is already up-to-date, you should install the cocoapods:

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

    $ sudo pod setup
    $ sudo pod install
    

And Viola! It is done. You'll see a Pods named folder within your project folder and the dependency you stated in the pod file will be apparent in Pods folder as a sub-folder.

Happy coding :)

Keith Smiley

The issue is with Mac OS X's default installation of Ruby. The Ruby/Gems installation is owned by root in the location you specified.

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

These installed your Ruby installation in your $HOME folder. This way your user owns the Ruby and gem executables.

Quick, easy, hacky solution:

sudo chmod -R 777 ~/.cocoapods
sudo chmod -R 777 ~/Library/Caches/CocoaPods
DaddyM

This is a known issue. There's more on the CocoaPods official web-site.

Snowcrash

Answering the original question:

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

When I do a 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.

I solved it by installing the most up to date version of Ruby. Instructions here: https://gorails.com/setup/osx/10.12-sierra I was then able to successfully run sudo gem update sudo gem install cocoapods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!