Permission Denied trying to restore npm cache

Hi there,

I am trying to cache the npm cache instead of node_modules, but I am getting Permission Denied on every file, as shown in the code block below.

I have tried doing this manually with restore_cache and save_cache, as well as using the circleci/node@5.0.2 orb, and getting the same error. Am I missing a step here?


version: 2.1
  node: circleci/node@5.0.2
      - checkout
      - node/install
      - node/install-packages:
          include-branch-in-cache-key: false
      - run ...

Log from “Restoring cache” step:

No cache is found for key: node-deps-arch1-linux-amd64-6_63-v1-tVrmW7rY1FjupiXfqrXjtXtNm0pD_cCdYnJem0wtgws=
No cache is found for key: node-deps-arch1-linux-amd64-6_63-v1-Baz7mJvAHL9frc8_R36h21KFe5Pi8eFljZYla27KELU=
Found a cache from build 70982 at node-deps-arch1-linux-amd64-6_63-v1-
Size: 199 MiB
Cached paths:
  * /home/circleci/.npm

Downloading cache archive...
Validating cache...

Unarchiving cache...
Skipping writing "home/circleci/.npm/_cacache/_cacache/content-v2/sha512/0b/61/241d7c17bcbb1baee7094d14b7c451efecc7ffcbd92598a0f13d313cc9ebc2a07e61f007baf58fbf94ff9a8695bdd5cae7ce03bbf1e94e93613a00f25f21" - open /home/circleci/.npm/_cacache/_cacache/content-v2/sha512/0b/61/241d7c17bcbb1baee7094d14b7c451efecc7ffcbd92598a0f13d313cc9ebc2a07e61f007baf58fbf94ff9a8695bdd5cae7ce03bbf1e94e93613a00f25f21: permission denied

I do notice that the files in the content-addressed store are read-only, so is this because the circleci user in the linux machine image itself already has some of those files to begin with?

The orb has a link to its github pages and I have found that raising issues like this there has a better chance of getting the author’s attention as they will get a notification regarding the post.

From what you have posted it would seem that only the orb author has the ability to change things as it is the orb that is used the circleci cache features to pull back a past directory structure, but RO flags on cached files does not make much sense.

You may also find that changing some of the parameters may help. By using include-branch-in-cache-key set to false you are allowing any past cache set from any build to be used. You can also clear the cache by changing cache-version.

@secobarbital Is it possible you are saving and restoring cache to two different environments? For instance, if you save the cache in jobA which runs with user1 and restore the cache in jobB which is using a different Docker image with a different user/permissions (user2).

If this is the case, it is very possible that the restore job user2 will not have permissions to access the files created by user1

This will not happen if the images are based off each other in the way the CircleCI convenience Docker images are.

As @rit1010 mentioned, you may also want to add to your cache key more specificity, especially the arch type. Caching Dependencies - CircleCI