Permission denied when restoring cache via node/install-packages on android/android-machine

Here’s a snippet from my configuration:

version: 2.1

orbs:
  macos: circleci/macos@2.3.4
  android: circleci/android@2.2.0
  node: circleci/node@5.1.0
  run-android-e2e-tests:
    executor:
      name: android/android-machine
      resource-class: xlarge
      tag: 2023.02.1

      - checkout
      - node/install
      - node/install-packages

      - run:
          name: Setup Additional Environment Dependencies

Which results in:

Found a cache from build 71 at node-deps-arch1-linux-amd64-6_85-v1-ci/initial-integration-eilblm9+_vy8yt18K5TIqnOhWGfb5d3FXXrFYxGt0H0=
Size: 108 MiB
Cached paths:
  * /home/circleci/.npm

Downloading cache archive...
Validating cache...

Unarchiving cache...
Skipping writing "home/circleci/.npm/_cacache/content-v2/sha512/00/49/ae5c775c0f7039d871d7c5a4e66256fcabfc4c121a113faec1dd3e0eabb95b992a2aae8319ce39c68f7fa2d62a37a5d9c5f2205856ee08963f9ce2107162" - open /home/circleci/.npm/_cacache/content-v2/sha512/00/49/ae5c775c0f7039d871d7c5a4e66256fcabfc4c121a113faec1dd3e0eabb95b992a2aae8319ce39c68f7fa2d62a37a5d9c5f2205856ee08963f9ce2107162: permission denied
Skipping writing "home/circleci/.npm/_cacache/content-v2/sha512/00/e2/2049009ea62258c0fdc04671b1fb95674eed870587736c63f8e5e2f0d6faf7cc1def64b7b279dd6c0bd8676dc39cf7f4ab33233944f42b906cf8692f59a3" - open /home/circleci/.npm/_cacache/content-v2/sha512/00/e2/2049009ea62258c0fdc04671b1fb95674eed870587736c63f8e5e2f0d6faf7cc1def64b7b279dd6c0bd8676dc39cf7f4ab33233944f42b906cf8692f59a3: permission denied
Skipping writing "home/circleci/.npm/_cacache/content-v2/sha512/01/21/41ba9d0ccf5bb28888c035a9f58f32d06a68bdcf53e86126428a...

The following thread covered what looks like the same issue.

By using just - node/install-packages without any additional parameters you are defining a very general environment that defaults to ~/.npm which can include RO files and problems if your execution environment changes.

Thanks for the quick reply.

Does this point to a bug in the orb? Shouldn’t the defaults (no additional parameters) work?

For clarity the entire cache fails to restore.

To be honest I do not use any of the CircleCI provided caching solutions as I use self hosted runners, which allow me to persist information on the runner or at a local proxy or repo depending on the task. This means I do not know the fine detail of what is going on in the .npm directory as I’ve never had an issue I’ve had to deal with.

I think the only issue with the orb is that it does not make clear the limitations of the defaults. There is no real alternative to using .npm/ as a default, but a lot happens under that directory, none of which the orb writer can track.

I guess the first question is - does it work if you set ‘with-cache’ to false or set ‘cache-version’ to a value other than ‘v1’ so invalidating the current cache?

If you set/change ‘cache-version’ and it works, does it still work when you re-run the job?

I’ll give these suggestions a try tomorrow. However, I suspect I’ll run into the same problems because this occurs on new branches where the initial job generates and stores a new cache. And subsequent jobs retrieve this new cache and yet get permission denied.