Unexpected EOF in archive when caching a big directory

Hi,

When I store node_module in the cache I have this success message :

Creating cache archive...
Uploading cache archive...
Stored Cache to yarn-cache-2-arch1-linux-amd64-6_63-circleci-NBP5Y_4GwrJ6SJdls0Zan4pUzXw+12TTu8bxP3+1f9M=
  * /home/circleci/product/frontend/node_modules

But I do a second run to restore the cache I have :

Found a cache from build 48 at yarn-cache-arch1-linux-amd64-6_63-circleci-NBP5Y_4GwrJ6SJdls0Zan4pUzXw+12TTu8bxP3+1f9M=
Size: 2.0 MB
Cached paths:
  * /home/circleci/project/frontend/node_modules
  * /home/circleci/project/frontend/bower_components

Downloading cache archive...
Validating cache...
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
Found a cache from build 48 at yarn-cache-arch1-linux-amd64-6_63-circleci-NBP5Y_4GwrJ6SJdls0Zan4pUzXw+12TTu8bxP3+1f9M=
Size: 2.0 MB
Cached paths:
  * /home/circleci/project/frontend/node_modules
  * /home/circleci/project/frontend/bower_components

Downloading cache archive...
Validating cache...
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
Found a cache from build 48 at yarn-cache-arch1-linux-amd64-6_63-circleci-NBP5Y_4GwrJ6SJdls0Zan4pUzXw+12TTu8bxP3+1f9M=
Size: 2.0 MB
Cached paths:
  * /home/circleci/project/frontend/node_modules
  * /home/circleci/project/frontend/bower_components

Downloading cache archive...
Validating cache...
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
Error validating cache from S3: exit status 2

Here are the steps to build the jobs :

test_frontend:
    <<: *defaults
    steps:
      - checkout
      - restore_cache:
          keys:
            - bower-cache
      - restore_cache:
          keys:
            - yarn-cache-{{ arch }}-{{ .Branch }}-{{ checksum "frontend/yarn.lock" }}
      - run: set -x && sudo curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose
      - run: docker-compose run frontend yarn
      - run: docker-compose run frontend ember test --silent
      - save_cache:
          key: yarn-cache-{{ arch }}-{{ .Branch }}-{{ checksum "frontend/yarn.lock" }}
          paths:
            - frontend/node_modules
      - save_cache:
          key: bower-cache
          paths:
            - frontend/bower_components

My node_module directory takes “356mo”. It works well withe bower, which is smaller.

What can I do?

2 Likes

I’m having the same issue. I don’t think it’s a matter of size though - my 104 MB node_modules cache restores successfully. Unfortunately my 77 MB gem cache fails each time with this error.

Did anybody ever find a way around this?

I’m having the same errors restoring the cache.

Having the same issue with a 271MB archive… can’t seems to recover from it even after we regenerate the archive by changing the cahe key… anybody figured out a way around it?

I’m getting this as well–has anyone managed to sort out what’s wrong?

Any official updates or workarounds?

I had same errors when restoring cache.
But, I overcame this error, so share how to solve.

Maybe your directory or file’s owner is diffrent from circleci.(In my case, root is owner)
So, I add this code in config.yml and solved.
sudo chown -R cirlcleci:circleci cache_target_directory_or_file

1 Like

@pencilrocketman’s workaround didn’t work for me.

Getting a bit desperate. Cache has never worked on our Ruby projects. Recently, caching on our Elixir projects has stopped working as well. A cached run will take 1.5 min. to complete. An uncached run will take 15-17 min. to complete.

Not sure what else to do other than jump ship.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.