Bitbucket pipeline pod install command error

Sami Shoaib
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 2, 2023

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

bitbucket-pipeline.yml

image: ruby:2.6
pipelines:

  custom:

    Staging_Build:

      - step:

          name: Build and Test

          script:

             - bundle install

             - pod install

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 3, 2023

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:

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

Sami Shoaib
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 4, 2023

i also got an email that we cannot generate iOS build in Bitbucket cloud we can use self hosted agent for releasing build only

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 6, 2023

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:

And the page for MacOS Runners:

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events