# Cache-pull failure because stack has changed (different stack workflows)

**URL:** <https://discuss.bitrise.io/t/cache-pull-failure-because-stack-has-changed-different-stack-workflows/14404>\
**Category:** Tooling Issues\
**Tags:** build-cache\
**Created:** [September 26, 2020, 4:12pm UTC](https://discuss.bitrise.io/t/cache-pull-failure-because-stack-has-changed-different-stack-workflows/14404 "2020-09-26T16:12:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gc1](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@gc1](https://discuss.bitrise.io/u/gc1)\
**Post date:** [September 26, 2020, 4:12pm UTC](https://discuss.bitrise.io/t/cache-pull-failure-because-stack-has-changed-different-stack-workflows/14404/1 "2020-09-26T16:12:58Z")

</div>

Hi, I’m running two workflows, one to execute some tests using the faster `linux-docker-android` stack, and the other to build a React Native (with iOS variant) application on the `osx-xcode-11.7.x` stack.

I noticed the `cache-pull` step is skipped when the previews workflow run was on a different stack, so all the cache time-saving is not taken advantage of, which in this case is ~15 minutes.

Some `cache-push` configuration options allow to set the fingerprint method or compression, but not some kind of prefix for the cache name to include the stack type and avoid invalidation when using different stacks.

This is the `cache-pull` output when it’s skipped:

```
+------------------------------------------------------------------------------+
| (3) cache-pull@2 |
+------------------------------------------------------------------------------+
| id: cache-pull |
| version: 2.1.6 |
| collection: https://github.com/bitrise-io/bitrise-steplib.git |
| toolkit: go |
| time: 2020-09-25T22:30:57Z |
+------------------------------------------------------------------------------+
| |
Config:
- CacheAPIURL: [REDACTED]
- DebugMode: false
- StackID: osx-xcode-11.7.x
- BuildSlug: 8815b0f4b39d850e
Downloading remote cache archive
Checking archive and current stacks
current stack id: osx-xcode-11.7.x
archive stack id: linux-docker-android
Cache was created on stack: linux-docker-android, current stack: osx-xcode-11.7.x
Skipping cache pull, because of the stack has changed
| |
+---+---------------------------------------------------------------+----------+
| ✓ | cache-pull@2 | 5.07 sec |
+---+---------------------------------------------------------------+----------+

```

Is there a way to take advantage of the cache when using different stacks on separate workflows?

---

<div class="post-metadata">

**Author:** ![bitce](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/bitce/32/1639_2.png) [@bitce](https://discuss.bitrise.io/u/bitce)\
**Post date:** [October 2, 2020, 7:59am UTC](https://discuss.bitrise.io/t/cache-pull-failure-because-stack-has-changed-different-stack-workflows/14404/2 "2020-10-02T07:59:20Z")

</div>

Hi @gc1!

Thanks for raising this question! Unfortunately, it isn’t possible to use the same cache across different stacks.

Cache is invalidated if used on a different stack than the one it was generated on. Cache is also not workflow dependent, only branch and app ID.

It came to our attention that this part of the logic isn’t documented well, so we’re working on updating the DevCenter with this information.

---

<div class="post-metadata">

**Author:** ![gc1](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@gc1](https://discuss.bitrise.io/u/gc1)\
**Post date:** [October 2, 2020, 12:04pm UTC](https://discuss.bitrise.io/t/cache-pull-failure-because-stack-has-changed-different-stack-workflows/14404/3 "2020-10-02T12:04:31Z")

</div>

Thanks for looking into updating the documentation.

It makes a lot of sense that the cache doesn’t work across different stacks, never the less, it would be of enormous help if the cache step could be stack-aware and save-restore multiple archives, one for each stack.

This would speed up the build process when using multiple stacks at a reduced cost.

---

<div class="post-metadata">

**Author:** ![gc1](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@gc1](https://discuss.bitrise.io/u/gc1)\
**Post date:** [October 2, 2020, 12:13pm UTC](https://discuss.bitrise.io/t/cache-pull-failure-because-stack-has-changed-different-stack-workflows/14404/4 "2020-10-02T12:13:05Z")

</div>

@bitce Probably a default option for the step, in which it specifies a cache prefix related to the stack name, to allow using it across different stacks.

Or probably options like CircleCI offers, in which the cache name can include the architecture/stack, branch name, file checksums, etc, as part of the name.

```auto
gem-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}

```

To restore the cache, it does partial or full name matches on the file names.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/2X/d/d901cf2aad020f2dd11918afc89ec2089bb87b35.png) [@system](https://discuss.bitrise.io/u/system)\
**Post date:** [November 1, 2020, 12:13pm UTC](https://discuss.bitrise.io/t/cache-pull-failure-because-stack-has-changed-different-stack-workflows/14404/5 "2020-11-01T12:13:05Z")

</div>

Closed on November 1, 2020, 12:13pm UTC

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