Cache path are absolute, breaking cache restores between executors

#1

Cache path are treated as semi-absolute, not relative as mentioned in the docs. This means one cannot restore caches from the “machine” executor in a “docker” executor.
This was reported here before by another user: Unable to restore cache saved in Docker to machine type job

config.yaml snippet:

  - save_cache:
      key: xyz-{{ .Branch }}-{{ .Revision }}
      paths:
        - .git

“Machine” executor saving cache:

Creating cache archive...
Uploading cache archive...
Stored Cache to xyz
  * /home/circleci/project/.git

Docker executor restoring cache:

Found a cache from build 615568 at [...]
Size: 5.3 GB
Cached paths:
  * /home/circleci/project/.git

Downloading cache archive...
Unarchiving cache...
tar: home/circleci: Cannot mkdir: Permission denied
tar: home/circleci/project/.git: Cannot mkdir: No such file or directory
tar: home/circleci: Cannot mkdir: Permission denied
[...]

The “cache paths” is clearly wrong, the absolute path made it into the cache despite the config is for the relative path.

0 Likes

#2

I have run into the same issue, only in my case between Docker and MacOS. I have currently been resorting to duplicating effort in the first MacOS job in my workflow, but that increases the amount of time required to execute the workflows, possibly by quite a lot depending on the work being redone.

0 Likes

#3

Part of the issue here is when you move things between executors, you run into issues with file permissions due to the users having different UUIDs, even if the same users exist between executors.

For this reason we recommend against this. I’ll make sure we add a note in our docs that this isn’t recommended.

0 Likes