CircleCI-Public / cimg-android

The CircleCI Android Docker Convenience Image.
MIT License
75 stars 37 forks source link

`Gem::FilePermissionError` when installing Ruby dependencies #43

Closed AlexKrupa closed 2 years ago

AlexKrupa commented 2 years ago

I encountered this problem when upgrading from a legacy Android image to the latest next-gen one.

Problem

Running ruby/install-deps step from Ruby orb fails like this:

Gemfile.lock is bundled with bundler version 2.3.3
Installing bundler 2.3.3
Fetching bundler-2.3.3.gem
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.7.0 directory.

After solving this for /var/libs/gems it fails again for /usr/local/bin directory.

Solution

Use chmod to grant directory permissions as described in this StackOverflow answer.

steps:
  # ...
  - run:
       name: Fix Ruby permissions
       command: sudo chmod -R a+w /var/lib/gems/ && sudo chmod -R a+w /usr/local/bin
  - ruby/install-deps
  # ...

I'm not sure if that's the best approach, but it solved the issue for me. Is it something that could be included in the image?

sw360cab commented 2 years ago

@AlexKrupa your solution works, you could even write it shorter

steps:
  - run:
       name: Fix Ruby permissions
       command: sudo chmod -R a+w /var/lib/gems/ /usr/local/bin
sw360cab commented 2 years ago

AFAIK

The variant are built starting from Dockerfile.template which uses as base image cimg/base:xxx

In my case I am using cimg/android:2022.01.1-node which is based upon cimg/base:2022.01.

The latter is based upon Ubuntu 20.04, where the issue may come from

circleci@9b41a1eb3b0a:~/project$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal

Indeed it looks like the issue has been fixed in following versions of Ubuntu starting from 20.10.4 on, see https://stackoverflow.com/a/68258603/2199731

FelicianoTech commented 2 years ago

This looks to be a problem with the Ruby orb. Closing for now.

sw360cab commented 2 years ago

@felicianotech does this mean that more recent versions of the ORBs won't be affected by this issue?