CIrcleCi failed to restore cache

Our builds started failing today randomly when it tried to restore a cache. During the cache restore the it seems that the restore is not happening and thus when the job goes to perform the steps against the directory it expects it fails since the cache didn’t restore it. Circleci shows that the save cache step completes successfully, but not the restore. Blow is what i’m seeing in the restore cache step…

Found a cache from build 7694 at my-directory-artifact-v1-123724cf-a26f-4aa5-a6f0555c64d26dec8
Size: 24 KiB
Cached paths:
  * /home/circleci/project/stage/mytarfile

Downloading cache archive...
Validating cache...

Unarchiving cache...
Skipping writing "home/circleci/project/stage/mytarartifact" - open /home/circleci/project/stage/mytarartifact: no such file or directory

Has anyone seen this issue before. Any advice on what might be happening

Hi @junior_ee,

Sorry to hear you are running into this issue.

We have rolled back a change on our end about an hour ago, but could you confirm for me if you are still running into this error with new builds?

@aaronclark Looks like the last build finished successfully! Thanks for the quick response, I didn’t notice anything in the status page so I thought it was something on our end.

Hello @aaronclark ,

I am running into the same issue right now :

Found a cache from build 259 at workspace-5d325f10-8723-4bbc-b905-d37c18b4cb18
Size: 405 MiB
Cached paths:
  * /home/circleci/project

Downloading cache archive...
Validating cache...

Unarchiving cache...
Skipping writing "home/circleci/project/" - mkdir /home/circleci: operation not supported

Can you post the save_cache and restore_cache sections of your config.yml so that we can see how you have expressed things.

For both save_cache and restore_cache the files and directories listed under paths: are normally expressed as off-sets to the current working directory which would be /home/circleci/project rather than a full path. It has been reported in the past that errors can be thrown if the full path is used as the restore process finds that parts of the path have different ownership rights to the current user.

Here is the save_cache on Linux Docker (/home/circleci/project/) :

      - save_cache:
          key: workspace-<< pipeline.id >>
          paths:
            - .

And here is the restore_cache on macos.m1.medium.gen1 :

      - restore_cache:
          name: Restore GIT
          keys:
            - workspace-<< pipeline.id >>

OK, from the info you have posted this issue is a permission issue. From the docs

is the following key statement

Caching files between different executors, for example, between Docker and machine, Linux, Windows or macOS, or CircleCI image and non-CircleCI image, can result in file permissions and path errors. These errors are often caused by missing users, users with different UIDs, and missing paths. Use extra care when caching files in these cases.

You will need to be more selective in your choice of files/paths. One thing you can try is to place everything into a subdirectory that you create at runtime. This way the subdirectory should be created by the circleci user, which I believe will also be the account used on a Mac target system. (I have never used the Mac environment so can not speak from experience). By having the directory created using a common user the restore may work.

The CircleCI cache is provided more as a way to get working files ‘cached’ between instances of the same job, running within the same working environment but between different workflow runs. You are using it as a way to move data between different jobs, deployed to different environments, which is not a well-documented process. This is not to say that it can not be done, but rather there is a lack of info regarding how it can be done and what the limitations are.

CircleCI also provides Workspaces as a way to share data between jobs executed by the same workflow. This may also meet your needs.

1 Like