0

I'm using the following yml file

image: uber/android-build-environment:latest

pipelines:
  default:
    - step:
        caches:
          - bundler
        script: # Modify the commands below to build your repository.
          - apt-get update && apt-get install -y awscli
          - apt-get install rubygems
          - gem install bundler
          - bundle install
          - bundle exec fastlane test
          - bundle exec fastlane build
definitions:
  caches:
    bundler: ./vendor

Please notice that I'm using an Android build environment image.

The build fails on

apt-get install rubygems with the error:

E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

so it looks like the build script does not run as root.

If I try to use sudo, it fails with the error

sudo: no tty present and no askpass program specified

What should I do to be able to run ruby gems with an Android build environment image?

kingston
  • 11,053
  • 14
  • 62
  • 116

2 Answers2

0

The uber/android-build-environment:latest uses a non-root user, which doesn't have permissions to run some commands, for example apt-get. You should rebuild an image with root user or temporary change the user to root. In your Dockerfile add:

USER root

install/updates

USER solr

See more details about the issue here How to install new packages into non-root Docker Container?

P.S. You don't need to run pipeline as root. If you run under the root inside the docker container, you will be able to install your dependencies.

Alexander Zhukov
  • 4,357
  • 1
  • 20
  • 31
0

I ended using a different android build env image:

image: mingc/android-build-box:v1.2.0

pipelines:
  default:
    - step:
        caches:
          - gradle
          - gradlewrapper
          - androidavd
          - bundler
        script:
          - apt-get update && apt-get install -y awscli
          - gem update --system
          - gem install bundler
          - gem install danger
          - bundle install
          - bundle exec fastlane test
          - bundle exec fastlane build
definitions:
  caches:
    gradlewrapper: ~/.gradle/wrapper
    androidavd: $ANDROID_HOME/.android/avd
    bundler: ./vendor
kingston
  • 11,053
  • 14
  • 62
  • 116