Cache path are absolute, breaking cache restores between executors


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