Error untarring cache: exit status 2


After adding cache/uncache steps to my build config, I’m getting this error on the uncache step.

This is problematic for me. But beyond that, this fails the build and it really seems like it shouldn’t. Having cached intermediate work is a speed up, but not strictly required.

Without this, 2.0 doesn’t seem to add much benefit to my builds.


Did you install the necessary dependencies to untar the cache? Another common problem is permissions related.


No, I didn’t install any particular dependencies for that purpose. But, given that the cache is created in the first place, it would seem to me like those dependencies are present.

And I’m pretty certain it’s not permissions, because I’m setting the mode to 777 on the cache directory before the uncache step.


Install tar, untar, and gzip and it will work okay.


A vague problem with the circleci docker images, is that if you’re trying to cache anything which the circleci user does not have write permissions to, then restoring it will fail.

Any suggestions for ways around this?


Maybe chowning before & after? I’ll open a bug ticket to address this.


Hey there, any update here? Circle 2 is fast enough that this isn’t a HUGE problem for us, but not having any caches work is definitely not ideal and will probably keep us on Circle 1 in the meantime.


Caching works properly at this time, but it does not address insufficient permissions yet. What are you trying to cache?


We’re having trouble to use caches for anything. For instance, we use yarn for JS dependency management and have the following:

      - restore_cache:
          key: yarn-{{ checksum "yarn.lock" }}
      - run:
          name: Yarn Install
          command: yarn install --cache-folder yarn-cache
      - save_cache:
          key: yarn-{{ checksum "yarn.lock" }}
            - ~/youearnedit/yarn-cache

which results in the same Error untarring cache: exit status 2 error that others have been seeing.

Our build setup is

    working_directory: ~/youearnedit
      - image: circleci/ruby:2.3.4-node-browsers
      - image: circleci/mongo:3.2.13
      - image: redis:3.2.3

Do you know why we’d be getting this error? Thank you!


I found the build in question and the reason is because you switched images. The cached node_modules was in /root and then you moved to /home/circleci, so there’s a permissions issue. The solution is to prefix your cache name with v1- so you can change the cache name if it ever becomes corrupt.

I imagine we’ll have a better solution at some point to clear out the cache on 2.0, but today the only solution is to change the name of the key.

EDIT: @kmcq It’s also worth noting you don’t need to install yarn as it’s already installed;

$ yarn --version

Cache not cleared


Thank you so much! We really appreciate you not only answering the question, but also digging into our specific instance! That is above and beyond :slight_smile:. Hopefully our experience will be helpful to others who find this forum.



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