Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You cannot run CocoaPods as root #6795

Closed
Ssunnyy opened this issue Jun 13, 2017 · 20 comments
Closed

You cannot run CocoaPods as root #6795

Ssunnyy opened this issue Jun 13, 2017 · 20 comments

Comments

@Ssunnyy
Copy link

Ssunnyy commented Jun 13, 2017

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

@orta
Copy link
Member

orta commented Jun 13, 2017

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.

@orta orta closed this as completed Jun 13, 2017
@Ssunnyy
Copy link
Author

Ssunnyy commented Jun 13, 2017

thanks for your response

@heidji
Copy link

heidji commented Jun 18, 2019

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

@amorde
Copy link
Member

amorde commented Jun 19, 2019

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

@heidji
Copy link

heidji commented Jun 19, 2019

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

@amorde
Copy link
Member

amorde commented Jun 22, 2019

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.

@heidji
Copy link

heidji commented Jun 23, 2019

@amorde thanks, will do

@matteocollina
Copy link

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

@amorde
Copy link
Member

amorde commented Feb 5, 2020

@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

@buscarini
Copy link

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.

@amorde
Copy link
Member

amorde commented Jun 17, 2020

@buscarini Jenkins could potentially be spawning the process as root

@buscarini
Copy link

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

@Agastya-Asthana
Copy link

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?

@heidji
Copy link

heidji commented Aug 10, 2020

@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

@seanreinhardtapps
Copy link
Contributor

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.

@yuguifly
Copy link

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 .

@mahmoud310
Copy link

I'm having the same issue

@Agastya-Asthana
Copy link

Agastya-Asthana commented Sep 23, 2020 via email

@MittapalliHareesh
Copy link

Hi,
am installing pods via "pod 1.10.0 install --verbose"

Am not seeing any error in the log but at the end failing with exit code:1


Pods

up to date, audited 1 package in 921ms

found 0 vulnerabilities
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:439:in `help!': �[31m[!] You cannot run CocoaPods as root.�[39m (CLAide::Help)

�[4mUsage:�[24m

$ �[32mpod�[39m �[32mCOMMAND�[39m

  CocoaPods, the Cocoa library package manager.

�[4mCommands:�[24m

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

�[4mOptions:�[24m

�[34m--allow-root�[39m   Allows CocoaPods to run as root
�[34m--silent�[39m       Show nothing
�[34m--version�[39m      Show the version of the tool
�[34m--verbose�[39m      Show more debugging information
�[34m--no-ansi�[39m      Show output without ANSI codes
�[34m--help�[39m         Show help banner of specified command
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:102:in `ensure_not_root_or_allowed!'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:48:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'

/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:439:in `help!': �[31m[!] You cannot run CocoaPods as root.�[39m (CLAide::Help)

�[4mUsage:�[24m

$ �[32mpod�[39m �[32mCOMMAND�[39m

  CocoaPods, the Cocoa library package manager.

�[4mCommands:�[24m

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

�[4mOptions:�[24m

�[34m--allow-root�[39m   Allows CocoaPods to run as root
�[34m--silent�[39m       Show nothing
�[34m--version�[39m      Show the version of the tool
�[34m--verbose�[39m      Show more debugging information
�[34m--no-ansi�[39m      Show output without ANSI codes
�[34m--help�[39m         Show help banner of specified command
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:102:in `ensure_not_root_or_allowed!'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:48:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'

===============================
command exit code: 1

Can someone please help me solving this.

@orta

@amorde
Copy link
Member

amorde commented Jun 29, 2021

@MittapalliHareesh if you're running cocoapods as root you'll need to pass the --allow-root flag. If that's not working for you, please open a new issue with repro steps

@CocoaPods CocoaPods locked and limited conversation to collaborators Jun 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests