# CIrcleCi failed to restore cache

**URL:** <https://discuss.circleci.com/t/circleci-failed-to-restore-cache/43393>\
**Category:** Caching Dependencies\
**Created:** [March 24, 2022, 11:51pm UTC](https://discuss.circleci.com/t/circleci-failed-to-restore-cache/43393 "2022-03-24T23:51:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![junior\_ee](https://avatars.discourse-cdn.com/v4/letter/j/d9b06d/32.png) [@junior\_ee](https://discuss.circleci.com/u/junior_ee)\
**Post date:** [March 24, 2022, 11:51pm UTC](https://discuss.circleci.com/t/circleci-failed-to-restore-cache/43393/1 "2022-03-24T23:51:41Z")

</div>

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…

```auto
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

---

<div class="post-metadata">

**Author:** ![aaronclark](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/aaronclark/32/31078_2.png) [@aaronclark](https://discuss.circleci.com/u/aaronclark)\
**Post date:** [March 25, 2022, 12:02am UTC](https://discuss.circleci.com/t/circleci-failed-to-restore-cache/43393/2 "2022-03-25T00:02:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![junior\_ee](https://avatars.discourse-cdn.com/v4/letter/j/d9b06d/32.png) [@junior\_ee](https://discuss.circleci.com/u/junior_ee)\
**Post date:** [March 25, 2022, 12:38am UTC](https://discuss.circleci.com/t/circleci-failed-to-restore-cache/43393/3 "2022-03-25T00:38:07Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![JB-CHAUVIN](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jb-chauvin/32/33637_2.png) [@JB-CHAUVIN](https://discuss.circleci.com/u/JB-CHAUVIN)\
**Post date:** [August 23, 2023, 7:54am UTC](https://discuss.circleci.com/t/circleci-failed-to-restore-cache/43393/4 "2023-08-23T07:54:27Z")

</div>

Hello @aaronclark ,

I am running into the same issue right now :

```auto
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

```

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [August 23, 2023, 9:58am UTC](https://discuss.circleci.com/t/circleci-failed-to-restore-cache/43393/5 "2023-08-23T09:58:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JB-CHAUVIN](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/jb-chauvin/32/33637_2.png) [@JB-CHAUVIN](https://discuss.circleci.com/u/JB-CHAUVIN)\
**Post date:** [August 23, 2023, 11:33am UTC](https://discuss.circleci.com/t/circleci-failed-to-restore-cache/43393/6 "2023-08-23T11:33:11Z")

</div>

Here is the save\_cache on Linux Docker (/home/circleci/project/) :

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

```

And here is the restore\_cache on macos.m1.medium.gen1 :

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

```

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [August 23, 2023, 12:00pm UTC](https://discuss.circleci.com/t/circleci-failed-to-restore-cache/43393/7 "2023-08-23T12:00:39Z")

</div>

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

> **[Caching Dependencies - CircleCI](https://circleci.com/docs/caching/)**
>
> This document is a guide to caching dependencies in CircleCI pipelines.

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.

> **[Using Workspaces to Share Data between Jobs - CircleCI](https://circleci.com/docs/workspaces/)**
>
> This document describes how to use workspaces to share data to downstream jobs in your workflows.
