react-native-circleci-orb icon indicating copy to clipboard operation
react-native-circleci-orb copied to clipboard

Restoring Cache : Failling to unarchive cache

Open josh-deprogram opened this issue 4 years ago β€’ 32 comments

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/[email protected]: exit status 1

Expected behavior

Use previous cache and carry on with the Yarn install

josh-deprogram avatar May 21 '20 06:05 josh-deprogram

@Naturalclar I see you recently touched this in https://github.com/react-native-community/react-native-circleci-orb/pull/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.

vonovak avatar May 23 '20 21:05 vonovak

Started getting this error as well. Orb version: 4.4.2

azizhk avatar May 25 '20 05:05 azizhk

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

mtt87 avatar Jun 02 '20 15:06 mtt87

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 avatar Jun 03 '20 09:06 mtt87

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.

mtt87 avatar Jun 03 '20 09:06 mtt87

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

chrisbruford avatar Jun 03 '20 09:06 chrisbruford

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?

mtt87 avatar Jun 03 '20 09:06 mtt87

Yes - we downgraded and await a fix to this

chrisbruford avatar Jun 03 '20 09:06 chrisbruford

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.

MateusAndrade avatar Jun 04 '20 14:06 MateusAndrade

Seeing this issue as well with 4.4.2

simba-joe avatar Jun 10 '20 20:06 simba-joe

Facing the same issue here: https://app.circleci.com/pipelines/github/react-native-community/react-native-viewpager/296/workflows/f47a2400-fc43-4aec-aedd-a3cafb80ed3e/jobs/972

in this PR: https://github.com/react-native-community/react-native-viewpager/pull/201

troZee avatar Jul 23 '20 12:07 troZee

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

mtt87 avatar Jul 23 '20 12:07 mtt87

The same for 4.2.2 https://app.circleci.com/pipelines/github/react-native-community/react-native-viewpager/302/workflows/f9554c1e-5dd8-4f27-ac8c-9745aae7e63c/jobs/993

Android works fine, but iOS does not work.

troZee avatar Jul 23 '20 12:07 troZee

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

mtt87 avatar Jul 23 '20 12:07 mtt87

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.

jdewells avatar Aug 27 '20 07:08 jdewells

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 avatar Sep 04 '20 17:09 m2mathew

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

donatoaguirre24 avatar Dec 09 '20 21:12 donatoaguirre24

I'm also still running into the same issue

dedan avatar Jan 18 '21 12:01 dedan

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:

  • https://circleci.com/docs/2.0/caching/#yarn-node
  • https://circleci.com/docs/2.0/yarn/
    • outcome: don't use /tmp/yarn for the cache, it might be on a different FS that doesn't treat symlinks as you might expect.

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

  • https://www.benpickles.com/articles/77-caching-yarn-workspaces-on-circleci

  • https://discuss.circleci.com/t/list-parameter-type/26705/6

airtonix avatar Jan 27 '21 06:01 airtonix

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 avatar Jan 27 '21 12:01 lukebrandonfarrell

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

lukebrandonfarrell avatar Feb 01 '21 12:02 lukebrandonfarrell

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?

Jose4gg avatar Feb 19 '21 14:02 Jose4gg

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

haruelrovix avatar Mar 04 '21 01:03 haruelrovix

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/[email protected]/: Cannot extract through symlink tmp/yarn/v6/[email protected] tmp/yarn/v6/[email protected]/node_modules/: Cannot extract through symlink tmp/yarn/v6/[email protected]/node_modules tmp/yarn/v6/[email protected]/node_modules/@babel/: Cannot extract through symlink tmp/yarn/v6/[email protected]/node_modules/@babel tmp/yarn/v6/[email protected]/node_modules/@babel/code-frame/: Cannot extract through symlink tmp/yarn/v6/[email protected]/node_modules/@babel/code-frame tmp/yarn/v6/[email protected]/node_modules/@babel/code-frame/.yarn-metadata.json: Cannot extract through symlink tmp/yarn/v6/[email protected]: exit status 1

I've opened a potential PR for this.

gretzky avatar Mar 24 '21 11:03 gretzky

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 https://github.com/react-native-community/react-native-circleci-orb/pull/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 avatar Mar 24 '21 12:03 vonovak

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.

matt-oakes avatar Mar 24 '21 12:03 matt-oakes

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.

gretzky avatar Mar 24 '21 14:03 gretzky

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.

ronwsmith avatar Jul 13 '21 18:07 ronwsmith

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

kieran-osgood avatar Jul 14 '21 07:07 kieran-osgood

Any update on this? getting the same error now.

bionara avatar Nov 24 '21 15:11 bionara