Cocoapods: You cannot run CocoaPods as root

Created on 13 Jun 2017  ยท  18Comments  ยท  Source: CocoaPods/CocoaPods

I can't execute pod install after using Jenkins to download the project

Run sudo pod install
/Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:439:in `help!': [!] You cannot run CocoaPods as root. (CLAide::Help)

Usage:

$ pod COMMAND

  CocoaPods, the Cocoa library package manager.

Commands:

+ cache      Manipulate the CocoaPods cache
+ env        Display pod environment
+ init       Generate a Podfile for the current directory
+ install    Install project dependencies according to versions from a
             Podfile.lock
+ ipc        Inter-process communication
+ lib        Develop pods
+ list       List pods
+ outdated   Show outdated project dependencies
+ repo       Manage spec-repositories
+ setup      Setup the CocoaPods environment
+ spec       Manage pod specs
+ update     Update outdated project dependencies and create new Podfile.lock

Options:

--silent     Show nothing
--version    Show the version of the tool
--verbose    Show more debugging information
--no-ansi    Show output without ANSI codes
--help       Show help banner of specified command
from /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.2.1/lib/cocoapods/command.rb:47:in `run'
from /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.2.1/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:22:in `load'
from /usr/local/bin/pod:22:in `<main>'

pod --version
1.2.1

pod install

โ€•โ€•โ€• MARKDOWN TEMPLATE โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•

Command

/usr/local/bin/pod install

Report

  • What did you do?

  • What did you expect to happen?

  • What happened instead?

Stack

   CocoaPods : 1.2.1
        Ruby : ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
    RubyGems : 2.6.7
        Host : Mac OS X 10.13 (17A264c)
       Xcode : 8.3.3 (8E3004b)
         Git : git version 2.11.0 (Apple Git-81)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib
Repositories : aliyun - https://github.com/aliyun/aliyun-specs.git @ 6729f85941274c455d270e4528639c442f60c2e0
               master - https://github.com/CocoaPods/Specs.git @ 5ca75a134cb66d0a37ec03da711086180e2e3acb
               taobao-baichuansdk-alibcspecs - http://repo.baichuan-ios.taobao.com/baichuanSDK/AliBCSpecs.git @ 290a149ec05366906a21220eab2492f238463421
               taobao-baichuansdk-alibcspecsmirror - http://repo.baichuan-ios.taobao.com/baichuanSDK/AliBCSpecsMirror.git @ 2c6d3877b8c242b088be0617d201f4d2d4ab1d7a

Plugins

cocoapods-deintegrate : 1.0.1
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.2.0
cocoapods-try         : 1.1.0

Podfile

source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/aliyun/aliyun-specs.git'

platform :ios, '8.0'

target "linGan" do

pod 'AFNetworking', '~> 3.0'
pod 'AliyunOSSiOS', '~> 2.6.0'
pod 'IQKeyboardManager'
pod 'Bugly'
pod 'YYKit'
pod 'UMengAnalytics-NO-IDFA'
pod 'AlicloudFeedback', '~> 3.1.0'
pod 'HyphenateLite'

end

Error

Errno::EACCES - Permission denied @ dir_s_mkdir - /Users/sunny/Desktop/LG_Dev/linGan/Pods
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:253:in `mkdir'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:253:in `fu_mkdir'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:227:in `block (2 levels) in mkdir_p'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:225:in `reverse_each'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:225:in `block in mkdir_p'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:211:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:211:in `mkdir_p'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.2.1/lib/cocoapods/sandbox.rb:58:in `initialize'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.2.1/lib/cocoapods/config.rb:184:in `new'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.2.1/lib/cocoapods/config.rb:184:in `sandbox'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.2.1/lib/cocoapods/command.rb:138:in `installer_for_config'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.2.1/lib/cocoapods/command/install.rb:38:in `run'
/Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.2.1/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.2.1/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:22:in `load'
/usr/local/bin/pod:22:in `<main>'

โ€•โ€•โ€• TEMPLATE END โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=Permission+denied+%40+dir_s_mkdir+-+%2FUsers%2Fsunny%2FDesktop%2FLG_Dev%2FlinGan%2FPods&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...
Found no similar issues. To create a new issue, please visit:
https://github.com/cocoapods/cocoapods/issues/new

Most helpful comment

CocoaPods 1.10.0.beta.1 is introducing a mechanism to run as root with the command line flag --allow-root or setting the Environment Variable COCOAPODS_ALLOW_ROOT.

All 18 comments

This is a feature we specifically added to protect people against shooting themselves in the foot with respect to file permissions.

You probably need to set up the permissions for your current Jenkins user to be able to write to any folder inside the project's directory.

thanks for your response

@orta hey, how do i disable this "feature" if i feel extra suicidal with my virtual machine?

You could probably use some Ruby monkey-patching to accomplish that but we don't have a supported way to disable this

look, i know you meant well but i have this process bound to a parent process that actually requires root access or that the normal user gets all privileges which defeats the purpose of supressing root access in the first place.
so i had to chown the whole computer in order to install a cordova plugin that uses cocoapods..

Sorry for the hassle but I don't see this being changed. Podspecs can include their own custom installation commands via prepare_command, and running those as root is quite the security risk.

If you think this should be changed, feel free to open a new issue suggesting the change, or a PR with a flag to disable this and it could be discussed there as well.

@amorde thanks, will do

Any update?

I have this error when I run my lane in CI/CD env.
This is my Gemfile:

source 'https://rubygems.org'
gem 'cocoapods', '1.5.0.beta.1'
gem "fastlane", "~> 2.131"

And when i exec bundle exec fastlane [myLaneName]
I receive this error during this step of the lane: pod install --deployment

@matteocollina this has been requested in #8929 - there are no updates other than that we'd welcome PRs for adding a CLI option for allowing root

I'm having the same issue, but I don't understand why. As far as I know I'm not running cocoapods as root, I'm using jenkins.

@buscarini Jenkins could potentially be spawning the process as root

Nevermind, the problem was that I restarted the machine and Jenkins was set up to run as root.

look, i know you meant well but i have this process bound to a parent process that actually requires root access or that the normal user gets all privileges which defeats the purpose of supressing root access in the first place.
so i had to chown the whole computer in order to install a cordova plugin that uses cocoapods..

@heidji What did you do exactly to install the cordova plugin?

@Agastya-Asthana was a some time ago, don't even use cordova anymore.
i just remember running ionic cordova build ios didn't always work and required a sudo to write in some folders that npm lacked privileges for.
it was either that or changing the privileges in 2 or so build folders but since I didn't believe that folder ownership should be a thing on a macOS VM image i thought i was above the process so i used sudo.
but then you had cocoapods, a module I hadn't heard of prior restricting my freedom on my virtual macOS machine, further extending the ridiculousness lol so i went on a baby rage here

CocoaPods 1.10.0.beta.1 is introducing a mechanism to run as root with the command line flag --allow-root or setting the Environment Variable COCOAPODS_ALLOW_ROOT.

Hello @ Agastya-Asthana I'm using a macOs VM too and I had the same problem, I tried infinited of commands and tips I found in google but it's so asy to fix ... o_O only put privilege to library folder, with this you can use the commands without sudo ....
I hopue it is usefull, for me it was a headache .

I'm having the same issue

Setup node so that it doesn't need to be run as root

On Mon, Sep 21, 2020 at 12:43 AM mahmoud310 notifications@github.com
wrote:

I'm having the same issue

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/CocoaPods/CocoaPods/issues/6795#issuecomment-695911096,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AETRD6DJ6Y3JI6TBSZIAUFTSG3RWRANCNFSM4DPAFFHA
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lzwjava picture lzwjava  ยท  3Comments

soleares picture soleares  ยท  3Comments

Curtis-Halbrook picture Curtis-Halbrook  ยท  3Comments

steffendsommer picture steffendsommer  ยท  3Comments

tlandsmancars picture tlandsmancars  ยท  3Comments