JS project permission denied on restore

Hi,

My build script looks like

version: 2
jobs:
  build:
    working_directory: ~/project

    docker:
      - image: circleci/node:10.15.3-browsers

    steps:
      - checkout

      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-

      - run: npm install

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run: JOBS=1 npm test # JOBS=1 because babel transpiler tries to start as many workers as it can https://github.com/emberjs/ember.js/issues/15641

Unfortunately when I run it fails on cache restore with errors like:

tar: root/project/node_modules/table/node_modules/lodash/xorBy.js: Cannot open: Permission denied
tar: root/project/node_modules/table/node_modules/lodash/xorWith.js: Cannot open: Permission denied
tar: root/project/node_modules/table/node_modules/lodash/zip.js: Cannot open: Permission denied
tar: root/project/node_modules/table/node_modules/lodash/zipObject.js: Cannot open: Permission denied

Any idea why?

What do you get on ls -l in the cached folder? It would be interesting to see the owner, group and perms on these files when they are restored.

Not sure what you mean my the cached folder, but there is a folder at this path /home/circleci/project that look like the project folder and has the following permissions.

drwxr-xr-x 10 circleci circleci

Managed to fix this issue by updating to cache key to force invalidation.

I mean the folders that you are saving in the cache:

      - save_cache:
          paths:
            - node_modules

In this case, the cache folder is “node_modules”. It would be interesting to see what the perms/owners were prior to caching.

Nevertheless, you solved it - nice work! You don’t need to add [solved] title hacks here - there is a full answer acceptance system. Open the icon bar on the response that solves your problem, and click the “solved” widget. That will mark it as solved, which will be helpful for future readers.