You cannot run CocoaPods as root Ruby

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)



  CocoaPods, the Cocoa library package manager.


+ 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
+ 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


--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 ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――


/usr/local/bin/pod install


  • What did you do?

  • What did you expect to happen?

  • What happened instead?


   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 - @ 6729f85941274c455d270e4528639c442f60c2e0
               master - @ 5ca75a134cb66d0a37ec03da711086180e2e3acb
               taobao-baichuansdk-alibcspecs - @ 290a149ec05366906a21220eab2492f238463421
               taobao-baichuansdk-alibcspecsmirror - @ 2c6d3877b8c242b088be0617d201f4d2d4ab1d7a


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


source ''
source ''

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'



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:

If none exists, create a ticket, with the template displayed above, on:

Be sure to first read the contributing guide for details on how to properly submit a ticket:

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:

Asked Oct 07 '21 02:10
avatar Ssunnyy

6 Answer:

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.

Answered Jun 13 '17 at 08:26
avatar  of orta

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

Answered Jun 18 '19 at 22:55
avatar  of heidji

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

Answered Jun 19 '19 at 05:34
avatar  of amorde

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..

Answered Jun 19 '19 at 06:04
avatar  of heidji

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.

Answered Jun 22 '19 at 18:48
avatar  of amorde

Any update?

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

source ''
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

Answered Feb 04 '20 at 23:55
avatar  of matteocollina