Permission denied when unpacking Cache


#1

Hi everyone,

I have a simple issue when trying to restore a cache of my Gemfiles.
I am using the circleci/ruby-2.3 docker image as the base.
When I run rebuild without cache it always works.

Here is the error:

tar: root/bearcloud-api/vendor/bundle: Cannot mkdir: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby: Cannot mkdir: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0: Cannot mkdir: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0/bin: Cannot mkdir: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0/bin/_guard-core: Cannot open: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0/bin/byebug: Cannot open: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0/bin/cap: Cannot open: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0/bin/capify: Cannot open: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0/bin/coderay: Cannot open: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0/bin/console: Cannot open: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0/bin/fission: Cannot open: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0/bin/fog: Cannot open: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0/bin/guard: Cannot open: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0/bin/htmldiff: Cannot open: Permission denied tar: root/bearcloud-api/vendor/bundle/ruby/2.3.0/bin/ldiff: Cannot open: Permission denied ...

Here is my config.yml:

``
jobs:
build:
working_directory: ~/bearcloud-api
environment:
- RAILS_ENV: “test”

docker:
  - image: circleci/ruby:2.3
  - image: timescale/timescaledb:latest
    command: [-cshared_preload_libraries=timescaledb]
  - image: bitnami/memcached:latest

steps:
  - checkout
  - run:
      name: Update bundler
      command: 'gem install bundler'
  - restore_cache:
      key: dependency-cache-{{ checksum "Gemfile" }}
  - run:
      name: Installing dependencies
      command: bundle install --path vendor/bundle
  - save_cache:
      key: dependency-cache-{{ checksum "Gemfile" }}
      paths:
        - vendor/bundle
  - run:
      name: Linking database configuration
      command: cp config/database.yml.ci config/database.yml
  - run:
      name: Setup database
      command: bin/rails db:setup
  - run:
      name: Prepare tests
      command: mkdir -p /tmp/reports
  - run:
      name: Run rspec
      command: bin/rspec  --format progress --format RspecJunitFormatter -o /tmp/reports/rspec.xml
  - store_test_results:
      path: /tmp/reports
  - deploy:
      command: |
        if [ "${CIRCLE_BRANCH}" == "develop" ];
          then cap staging deploy;
        fi
  - deploy:
      command: |
        if [ "${CIRCLE_BRANCH}" == "master" ];
          then cap staging production;
        fi

``


#2

Hey there, is it possible that you were originally using the stock ruby:2.3 image (or another image with root as the default user) and saved a cache from that where ~/bearcloud-api expanded to /root/bearcloud-api, but are now trying to restore it onto the circleci/ruby image which uses a different user? If this is the case, updating your cache key to something like v2-dependency-cache... should stop the build from using the old cache.


#3

Hi @anon52070816, since couple of weeks, we experience similar problem in an open source project, but it seems to happen inconsistently.

Here’s the link to the project: https://github.com/facebook/jest
Here’s a CircleCI report failing for the PR: https://circleci.com/gh/facebook/jest/14275
You can see that on master branch, the cache is successfully restored for every workflow.

Would love to get some guidance on what is wrong, especially if it’s in our config (to be found in the repo).

P.S. I’d add more links to ease things out, but am limited as a new user :smiley:


#4

I am encountering the same issue.


#5