Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restoring Cache : Failling to unarchive cache #66

Open
josh-deprogram opened this issue May 21, 2020 · 32 comments
Open

Restoring Cache : Failling to unarchive cache #66

josh-deprogram opened this issue May 21, 2020 · 32 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@josh-deprogram
Copy link

josh-deprogram commented May 21, 2020

Hitting problems when trying to rerun a build. the pre Yarn install step of Restoring the Cache is failing, is there a way around skipping this step,

Orb version

4.4.2

What happened

Fails to unarchive cache

Size: 324 MiB
Cached paths:
  * /tmp/yarn

Downloading cache archive...
Validating cache...

Unarchiving cache...

Failed to unarchive cache

Error untarring cache: Error extracting tarball /var/folders/1b/gl7yt7ds26vcyr1pkgld6l040000gn/T/cache984330157 : tmp/yarn/: Cannot extract through symlink tmp/yarn tmp/yarn/v4/: Cannot extract through symlink tmp/yarn/v4 tmp/yarn/v4/.tmp/: Cannot extract through symlink tmp/yarn/v4/.tmp tmp/yarn/v4/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e/: Cannot extract through symlink tmp/yarn/v4/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e tmp/yarn/v4/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e/node_modules/: Cannot extract through symlink tmp/yarn/v4/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e/node_modules tmp/yarn/v4/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e/node_modules/@babel/: Cannot extract through symlink tmp/yarn/v4/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e/node_modules/@babel tmp/yarn/v4/npm-@babel-code-frame-7.8.3-33e25903d7481181534e12ec0a25f16b6fcf419e/node_modules/@babel/code-frame/: Cannot extract through symlink tmp/yarn/v4/npm-@babel-code-frame-7.8.3-33e25903d7481: exit status 1

Expected behavior

Use previous cache and carry on with the Yarn install

@josh-deprogram josh-deprogram added the bug Something isn't working label May 21, 2020
@vonovak
Copy link
Member

vonovak commented May 23, 2020

@Naturalclar I see you recently touched this in #59. On what type of runner were you experiencing the problems (mac/linux)?. Any idea what can be wrong? I'm also seeing this, on a mac runner. Thanks.

@azizhk
Copy link

azizhk commented May 25, 2020

Started getting this error as well.
Orb version: 4.4.2

@mtt87
Copy link

mtt87 commented Jun 2, 2020

Confirm it's happening on 4.4.2 only on Mac environment for me

@mtt87
Copy link

mtt87 commented Jun 3, 2020

Some more info, in my case it says

Found a cache from build 559 at yarn-cache-arch1-darwin-amd64-6_58-...

But I'm now at build 592, is there a way to say if restoring the cache goes wrong then ignore it and install everything from scratch?

@mtt87
Copy link

mtt87 commented Jun 3, 2020

After reading this
https://support.circleci.com/hc/en-us/articles/115015426888-Clear-project-dependency-cache
I set an environment variable CACHE_VERSION with value v2 and it seems like it solved the issue.

@chrisbruford
Copy link

@mtt87 when you first set it, you have changed the comparitor and so it won't be able to find a valid cache to use...thus it creates a new one and everything works.

I found that on the next attempt to build it will use your value v2 and find a matching cache, try to unarchive it and you'll get the same error as before.

@mtt87
Copy link

mtt87 commented Jun 3, 2020

Damn, that's a good point I'll try again soon to verify if it still happening.

Have you tried to downgrade to 3.2.2 to see if it works?

@chrisbruford
Copy link

Yes - we downgraded and await a fix to this

@MateusAndrade
Copy link
Member

Facing the same issue on xcode: 11.5.0 orb 4.4.2, solved running a simple yarn install --frozen-lockfile --non-interactive since I don't need to cache this folder at a specific step.

@simba-joe

This comment has been minimized.

@mtt87
Copy link

mtt87 commented Jul 23, 2020

Latest working version for me it's 4.2.2 FYI in case you wanna downgrade

@troZee
Copy link
Member

troZee commented Jul 23, 2020

@mtt87
Copy link

mtt87 commented Jul 23, 2020

Add an env variable to your project if you don't already have it CACHE_VERSION and use 2, or if you already have it, increase it.
I remember this fixed it for me with 4.2.2 and it still works today

@jdewells
Copy link

We're finding that we need to change the CACHE_VERSION for every run, and so far we've only found a way to do it manually by changing the project settings.

@m2mathew
Copy link

m2mathew commented Sep 4, 2020

We're finding that we need to change the CACHE_VERSION for every run, and so far we've only found a way to do it manually by changing the project settings.

With version 4.4.2 I have the same experience with the rn/ios_build job. I set all of this up with Android weeks ago, and the save/restore from cache has been flawless. Setting up the iOS side has been more of a pain.

Here is how we are using the rn orb's job in our workflow. It mostly matches the examples in the documentation (some names withheld to protect the innocent):

- rn/ios_build:
    build_configuration: Debug
    detox_configuration: ios.sim.staging
    device: iPhone 11 Pro
    name: build_ios_debug
    node_version: '12.18'
    project_path: ios/ProjectName.xcworkspace
    project_type: workspace
    scheme: ProjectName-staging
    start_metro: true
    requires:
      - analyze_js
      # ↑ We changed that to the American spelling :) 🇺🇸
  1. The build fails with an error like this:

image

Found a cache from build 2500 at yarn-cache-arch1-darwin-amd64-6_58-CtErNzrQbrt0boxXcoHOSPYkhQO77C0mVdN+cOWwdlQ=-pkNLpKB43oV0NLrI2IjZ4BpTEqiMriIdA7xqTvUeC04=-v3
Size: 378 MiB
Cached paths:
  * /tmp/yarn

Downloading cache archive...
Validating cache...

Unarchiving cache...

Failed to unarchive cache

Error untarring cache: Error extracting tarball /var/folders/1b/gl7yt7dS26vcyr1pkgld6l050000gn/T/cache789244379 : tmp/yarn/: Cannot extract through symlink tmp/yarn tmp/yarn/v4/: Cannot extract through symlink tmp/yarn/v4 tmp/yarn/v4/.tmp/: Cannot extract through symlink tmp/yarn/v4/.tmp tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/: Cannot extract through symlink tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403 tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.buckconfig: Cannot extract through symlink tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.buckconfig tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.editorconfig: Cannot extract through symlink tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.editorconfig tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.eslintignore: Cannot extract through symlink tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.eslintignore tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.eslintrc.js: Cannot extract through symlink tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.eslintrc.js tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.flowconfig: Cannot extract thro: exit status 1
  1. We go to the Circle CI environment variables, remove the CACHE_VERSION, and then add new variable with the same name but an incremented value.
    • e.g., remove CACHE_VERSION with value of v2 and add CACHE_VERSION with a value of v3
    • example url for Circle Environment Variables – https://app.circleci.com/settings/project/github/your-org-name/your-repo-name/environment-variables

The cache is successfully restored on the next run, but will fail on subsequent runs. It seems like the restore from cache has somehow changed on a macos executor.

Next steps for me

My next steps are to use the individual commands from the rn orb mixed in with my own save/restore cache commands, though I would love to use the orb here instead!

@donatoaguirre24
Copy link

Hi guys! Did any found a solution or workaround to this issue?

@dedan
Copy link

dedan commented Jan 18, 2021

I'm also still running into the same issue

@airtonix
Copy link

Looking into this.

We had to make the swissknife and react-native orbs local to our setup (we have unoffical orbs disabled).

But this means I can make changes!

So, investigating leads me to these links:

The other thing I noticed was that for monorepos, caching will need to be more nuanced:

@lukebrandonfarrell
Copy link
Contributor

lukebrandonfarrell commented Jan 27, 2021

We're finding that we need to change the CACHE_VERSION for every run, and so far we've only found a way to do it manually by changing the project settings.

With version 4.4.2 I have the same experience with the rn/ios_build job. I set all of this up with Android weeks ago, and the save/restore from cache has been flawless. Setting up the iOS side has been more of a pain.

Here is how we are using the rn orb's job in our workflow. It mostly matches the examples in the documentation (some names withheld to protect the innocent):

- rn/ios_build:
    build_configuration: Debug
    detox_configuration: ios.sim.staging
    device: iPhone 11 Pro
    name: build_ios_debug
    node_version: '12.18'
    project_path: ios/ProjectName.xcworkspace
    project_type: workspace
    scheme: ProjectName-staging
    start_metro: true
    requires:
      - analyze_js
      # ↑ We changed that to the American spelling :) 🇺🇸
  1. The build fails with an error like this:

image

Found a cache from build 2500 at yarn-cache-arch1-darwin-amd64-6_58-CtErNzrQbrt0boxXcoHOSPYkhQO77C0mVdN+cOWwdlQ=-pkNLpKB43oV0NLrI2IjZ4BpTEqiMriIdA7xqTvUeC04=-v3
Size: 378 MiB
Cached paths:
  * /tmp/yarn

Downloading cache archive...
Validating cache...

Unarchiving cache...

Failed to unarchive cache

Error untarring cache: Error extracting tarball /var/folders/1b/gl7yt7dS26vcyr1pkgld6l050000gn/T/cache789244379 : tmp/yarn/: Cannot extract through symlink tmp/yarn tmp/yarn/v4/: Cannot extract through symlink tmp/yarn/v4 tmp/yarn/v4/.tmp/: Cannot extract through symlink tmp/yarn/v4/.tmp tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/: Cannot extract through symlink tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403 tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.buckconfig: Cannot extract through symlink tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.buckconfig tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.editorconfig: Cannot extract through symlink tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.editorconfig tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.eslintignore: Cannot extract through symlink tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.eslintignore tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.eslintrc.js: Cannot extract through symlink tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.eslintrc.js tmp/yarn/v4/.tmp/ae76De6c779b0c17fc78aa8d370ed403/.flowconfig: Cannot extract thro: exit status 1
  1. We go to the Circle CI environment variables, remove the CACHE_VERSION, and then add new variable with the same name but an incremented value.

    • e.g., remove CACHE_VERSION with value of v2 and add CACHE_VERSION with a value of v3
    • example url for Circle Environment Variables – https://app.circleci.com/settings/project/github/your-org-name/your-repo-name/environment-variables

The cache is successfully restored on the next run, but will fail on subsequent runs. It seems like the restore from cache has somehow changed on a macos executor.

Next steps for me

My next steps are to use the individual commands from the rn orb mixed in with my own save/restore cache commands, though I would love to use the orb here instead!

@m2mathew Appreciate the detailed explanation. I am very new to Circle CI and I couldn't for the life of me figure out how to set environment variables, for those having the same issue as me, i.e. where the hell do you set CACHE_VERSION, as Mathew suggested, it is in the Circle CI UI and here is the link:

https://app.circleci.com/settings/project/github/your-org-name/your-repo-name/environment-variables

@lukebrandonfarrell
Copy link
Contributor

@airtonix Would you mind sharing your "swissknife and react-native orbs local to our setup" approach ?

@Jose4gg
Copy link

Jose4gg commented Feb 19, 2021

Hi, I'm dealing with this issue, and I have to change the CACHE_VERSION almost every new PR, do we have a better workaround to fix this bug in the meantime?

@haruelrovix
Copy link

Hi, I'm dealing with this issue, and I have to change the CACHE_VERSION almost every new PR, do we have a better workaround to fix this bug in the meantime?

Have you checked this post? @Jose4gg
https://support.circleci.com/hc/en-us/articles/360056920051--Error-untarring-cache-when-running-a-macOS-job

@gretzky
Copy link
Contributor

gretzky commented Mar 24, 2021

This is still happening, v5.0.0 on the rn/ios_build step.

My config at this step:

- rn/ios_build:
      name: build_ios_release
      project_path: ios/MyApp.xcodeproj
      device: "iPhone 12"
      build_configuration: Release
      scheme: MyApp
      requires:
        - analyze_js

Here's the entire error:

Found a cache from build 846 at yarn-cache-arch1-darwin-amd64-6_58-D0_AuAkbuS7gt7h+QkuuifdD4ggj_6o0mKXP8aewiEQ=-XUzc4oblUuD6VhRoBYEv7OCtEibCDWiNuAbxRwyDlRk=-v4
Size: 275 MiB
Cached paths:
  * /tmp/yarn

Downloading cache archive...
Validating cache...

Unarchiving cache...

Failed to unarchive cache

Error untarring cache: Error extracting tarball /var/folders/6y/gy9gggt14379c_k39vwb50lc0000gn/T/cache725626886 : tmp/yarn/: Cannot extract through symlink tmp/yarn tmp/yarn/v6/: Cannot extract through symlink tmp/yarn/v6 tmp/yarn/v6/.tmp/: Cannot extract through symlink tmp/yarn/v6/.tmp tmp/yarn/v6/npm-@babel-code-frame-7.10.4-integrity/: Cannot extract through symlink tmp/yarn/v6/npm-@babel-code-frame-7.10.4-integrity tmp/yarn/v6/npm-@babel-code-frame-7.10.4-integrity/node_modules/: Cannot extract through symlink tmp/yarn/v6/npm-@babel-code-frame-7.10.4-integrity/node_modules tmp/yarn/v6/npm-@babel-code-frame-7.10.4-integrity/node_modules/@babel/: Cannot extract through symlink tmp/yarn/v6/npm-@babel-code-frame-7.10.4-integrity/node_modules/@babel tmp/yarn/v6/npm-@babel-code-frame-7.10.4-integrity/node_modules/@babel/code-frame/: Cannot extract through symlink tmp/yarn/v6/npm-@babel-code-frame-7.10.4-integrity/node_modules/@babel/code-frame tmp/yarn/v6/npm-@babel-code-frame-7.10.4-integrity/node_modules/@babel/code-frame/.yarn-metadata.json: Cannot extract through symlink tmp/yarn/v6/npm-@babel-code-frame-7.10.4-integr: exit status 1

I've opened a potential PR for this.

@vonovak
Copy link
Member

vonovak commented Mar 24, 2021

Hello, I talked with Matt and he does not have time for OSS so he likely won't be responsive in this repo going forward.
While I'm also reducing my free time that I spend with open source, I will be available here to review and merge pull requests.

regarding this issue, I believe it was caused by #59

The solution is that someone who is bothered by this issue should investigate the proper fix and contribute a PR. Thank you for your understanding! 🙂

@vonovak vonovak added the help wanted Extra attention is needed label Mar 24, 2021
@matt-oakes
Copy link
Member

Thanks for the message @vonovak! It's true that I'll likely be stepping back for this a bit more and I'm happy for any help that anyone can provide on this.

Seeing as this is a common issue, and I had a spare half hour, I've implemented a workaround to allow you to disable caching using parameters on the commands and jobs. Details are in this commit and it's released in v5.1.0.

This is only a workaround to allow you to move forward with no cache, but I agree that someone who's experiencing this issue should look into a proper fix which allows the cache to be kept there as it can vastly speed up build times.

@gretzky
Copy link
Contributor

gretzky commented Mar 24, 2021

Thanks @matt-oakes and @vonovak for the quick response. Being able to disable the cache will definitely help for now. I've submitted a fix (#88), however I'm not entirely sure this a full fix, but it does allow the caches to be used.

@ronwsmith
Copy link
Contributor

I submitted PR #103 which made it into orb version 5.4.0. This allows you to undo the pathing change that seemed to have introduced this issue. You can achieve that by using yarn_cache_folder: ~/.cache/yarn in the ios_build or ios_build_and_test jobs.

I've run my build several times with this config change and haven't run into the permissions issue that drove that breaking change initially.

@kieran-osgood
Copy link
Contributor

I submitted PR #103 which made it into orb version 5.4.0. This allows you to undo the pathing change that seemed to have introduced this issue. You can achieve that by using yarn_cache_folder: ~/.cache/yarn in the ios_build or ios_build_and_test jobs.

I've run my build several times with this config change and haven't run into the permissions issue that drove that breaking change initially.

As a note for anyone planning on utilising this new yarn_cache_folder, just be aware that changing to the orb v5.4.0 and adding the new cache param above may still match the old location /tmp/yarn if there exists a matching checksum (I just had this) - I just chose to upgrade a package I was already planning on upgrading anyway, so they stopped matching and now the restore goes through perfectly!

Thanks @ronwsmith - this was a real pain point when i got the orb setup a few months ago lol

@bionara
Copy link

bionara commented Nov 24, 2021

Any update on this? getting the same error now.

@dtran-ellevest
Copy link

@kieran-osgood is there a way to get Circle to stop matching the old checksum without upgrading/removing a package?

@kieran-osgood
Copy link
Contributor

@kieran-osgood is there a way to get Circle to stop matching the old checksum without upgrading/removing a package?

Not a clue im afraid!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.