I have a project that saves and restores 2 caches. 1 of them works as expected while the other reports:
Error validating cache: Error listing tarball /tmp/cache632340460: exit status 2
Both caches are located within $HOME and I’m not really sure why one would work while the other would fail. What information would be useful in figuring this out? My project uses a machine executor rather than docker, for what it’s worth, and the data being cached/restored for both caches are coming from/going to directories mounted as volumes in docker.
Hi @moorecp, welcome to the CircleCI Discuss community! Without looking at your build, here are a few things I can think of:
Usually, the save_cache
function skips when the same cache-key already stored. If your workflow is using parallelism, It’s better to separate the cache step to another job to avoid this.
If you are using docker-compose with the machine executor, the vendor folder has root permissions. Since the user of machine executor is a CircleCI user, could you try changing it to the root owner and see if you continue to experience this error?
I’m experiencing the same issue. Below is the example to reproduce, in which I used docker-compose to build serverless image.
jobs:
deploy:
machine:
docker_layer_caching: true
user: root
steps:
- checkout
- run: docker-compose build
- restore_cache:
keys:
- serverless-python-requirements-v1-{{ checksum "requirements.txt" }}
- run: |
docker-compose run --rm \
-e STAGE=${STAGE} \
serverless bash -c "yarn --frozen-lockfile && yarn sls deploy --stage ${STAGE}"
- save_cache:
paths:
- .serverless-python-requirements-cache
key: serverless-python-requirements-v1-{{ checksum "requirements.txt" }}
CI run gives the following error:
Restoring Cache
Found a cache at serverless-python-requirements-v3-xxx
Size: 335 B
Cached paths:
* /home/circleci/project/.serverless-python-requirements-cache
Downloading cache archive...
Validating cache...
Found a cache at serverless-python-requirements-v3-xxx
Size: 335 B
Cached paths:
* /home/circleci/project/.serverless-python-requirements-cache
Downloading cache archive...
Validating cache...
Found a cache at serverless-python-requirements-v3-xxx
Size: 335 B
Cached paths:
* /home/circleci/project/.serverless-python-requirements-cache
Downloading cache archive...
Validating cache...
Error validating cache: Error listing tarball /tmp/cache259776929: exit status 2