Bitbucket pipeline pod install command error
Asked by Sami Shoaib:

This is my script when this script is triggered in bitbucket-pipeline.yml i received error that you cannot run pod as root user

basically -pod install command does not work  

this is my gem file in xcode project for iOS

**GemFile**

source "<https://rubygems.org>"

gem 'fastlane'

gem 'fastlane-plugin-versioning'

gem "cocoapods", "1.12.1"

gem "xcode-install"

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')

eval_gemfile(plugins_path) if File.exist?(plugins_path)

**Bitbucket pipline error screen shot**

**![Screenshot 2023-10-02 at 10.58.08 PM.png](/t5/image/serverpage/image-id/284047iD65BA4C0B1D5AC02/image-size/large?v=v2&px=999 "Screenshot 2023-10-02 at 10.58.08 PM.png")**

**bitbucket-pipeline.yml**   

**image: ruby:2.6**   
pipelines:

custom:

Staging_Build:

- step:

name: Build and Test

script:

- bundle install

- pod install


Answers:
author: Theodora Boudale
body: Hi Sami and welcome to the community!

The error in the output of the command says that you cannot run CocoaPods as root.

Just to give you some context, Bitbucket Pipelines builds run in Docker containers. For every step of the pipeline, a Docker container starts (the build container) using the image you have specified in your bitbucket-pipelines.yml file. The repo is cloned in that container and then the commands of that step's script are executed. When the step is finished, the container gets destroyed.

The default user in many containers is root. I see in the screenshot you posted that the option **--allow-root** is available for the **pod install** command. One option would be to try running the command with **--allow-root** **.**

Alternatively, you can run a Pipelines step as a different user by specifying the **run-as-user** option:

* <https://support.atlassian.com/bitbucket-cloud/docs/docker-image-options/#Run-as-user>

As mentioned in the documentation, the specified user UID needs to be a user already defined in the Docker image (in your case the DockerHub image **ruby:2.6**) and should have a valid home directory.

If you have Docker installed on your computer, you can start locally a Docker container based on ruby:2.6 with the command

```
docker run -it --entrypoint=/bin/bash ruby:2.6
```

Inside the container, you can run the command **cat /etc/passwd** to see the image's users and their UID.

You can then run this specific Pipelines step as a different user.

Please feel free to reach out if you have any questions!

Kind regards,  
Theodora

comments: author: Sami Shoaib
body: i also got an email that we cannot generate iOS build in Bitbucket cloud we can use self hosted agent for releasing build only


author: Theodora Boudale
body: Hi Sami,

Pipelines builds run on a Kubernetes cluster of Linux Docker hosts. If your build needs to run on MacOS hardware, then, yes, you can use a MacOS self-hosted runner.

This is the documentation for runners:

* <https://support.atlassian.com/bitbucket-cloud/docs/runners/>

And the page for MacOS Runners:

* <https://support.atlassian.com/bitbucket-cloud/docs/set-up-runners-for-macos/>

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud