# Flutter build fails if cache used and pub has custom git repository dependencies

**URL:** <https://discuss.bitrise.io/t/flutter-build-fails-if-cache-used-and-pub-has-custom-git-repository-dependencies/10051>\
**Category:** Builds\
**Tags:** flutter\
**Created:** [August 28, 2019, 9:04am UTC](https://discuss.bitrise.io/t/flutter-build-fails-if-cache-used-and-pub-has-custom-git-repository-dependencies/10051 "2019-08-28T09:04:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dominik.roszkowski](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@dominik.roszkowski](https://discuss.bitrise.io/u/dominik.roszkowski)\
**Post date:** [August 28, 2019, 9:04am UTC](https://discuss.bitrise.io/t/flutter-build-fails-if-cache-used-and-pub-has-custom-git-repository-dependencies/10051/1 "2019-08-28T09:04:06Z")

</div>

## Description of the issue

When

- using default cache pull and cache push steps
- having dependencies that are stored in git repository instead of pub.dev package repository  
e.g. pubspec.yaml has:

```auto
  leancode_logging:
    git:
      url: git@bitbucket.name-team/corelibrary-flutter.git
      path: packages/logging
      ref: 838e54d

```

Build crashes with error:

```auto
Running "flutter pub get" in mobile...                          
Cannot open file, path = '/usr/local/flutter/.pub-cache/git/corelibrary-flutter-3c4e423ff318ca0411059e0db3bae806146cab8d/.git/pub-packages' (OS Error: No such file or directory, errno = 2)
---- Log transcript ----
FINE: Pub 2.4.0

```

When disabling cache the build succeeds.

## Environment:

Sample build that crashed second time in a row:  
`28c34e317c3c93b5` - [https://app.bitrise.io/build/28c34e317c3c93b5#?tab=log](https://app.bitrise.io/build/28c34e317c3c93b5#?tab=log)

**Stack:**  
Visual Studio for Mac, stable

---

<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:** [September 4, 2019, 6:07am UTC](https://discuss.bitrise.io/t/flutter-build-fails-if-cache-used-and-pub-has-custom-git-repository-dependencies/10051/2 "2019-09-04T06:07:14Z")

</div>

Sorry for the delay here @dominik.roszkowski, we have created a task for the team to investigate this. Can you please enable Support Access on this app?

---

<div class="post-metadata">

**Author:** ![dominik.roszkowski](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@dominik.roszkowski](https://discuss.bitrise.io/u/dominik.roszkowski)\
**Post date:** [September 4, 2019, 8:59am UTC](https://discuss.bitrise.io/t/flutter-build-fails-if-cache-used-and-pub-has-custom-git-repository-dependencies/10051/3 "2019-09-04T08:59:09Z")

</div>

Thanks, support enabled for [https://app.bitrise.io/app/c47126b04acd7b26#/settings](https://app.bitrise.io/app/c47126b04acd7b26#/settings)

You need to add cache steps again, because I removed them after the described incident.

---

<div class="post-metadata">

**Author:** ![dominik.roszkowski](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@dominik.roszkowski](https://discuss.bitrise.io/u/dominik.roszkowski)\
**Post date:** [September 4, 2019, 2:31pm UTC](https://discuss.bitrise.io/t/flutter-build-fails-if-cache-used-and-pub-has-custom-git-repository-dependencies/10051/4 "2019-09-04T14:31:31Z")

</div>

The same problem can be seen here [https://app.bitrise.io/build/7b78f40c91d2f8a5#?tab=log](https://app.bitrise.io/build/7b78f40c91d2f8a5#?tab=log)

---

<div class="post-metadata">

**Author:** ![dominik.roszkowski](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@dominik.roszkowski](https://discuss.bitrise.io/u/dominik.roszkowski)\
**Post date:** [September 6, 2019, 10:36am UTC](https://discuss.bitrise.io/t/flutter-build-fails-if-cache-used-and-pub-has-custom-git-repository-dependencies/10051/5 "2019-09-06T10:36:47Z")

</div>

Again similar situation here [https://app.bitrise.io/build/399355aa59025c1a#?tab=log](https://app.bitrise.io/build/399355aa59025c1a#?tab=log)

---

<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:** [October 6, 2019, 10:40am UTC](https://discuss.bitrise.io/t/flutter-build-fails-if-cache-used-and-pub-has-custom-git-repository-dependencies/10051/6 "2019-10-06T10:40:24Z")

</div>

Closed on October 6, 2019, 10:40am UTC

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

---

<div class="post-metadata">

**Author:** ![laszlo.pusok](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@laszlo.pusok](https://discuss.bitrise.io/u/laszlo.pusok)\
**Post date:** [December 10, 2019, 12:03pm UTC](https://discuss.bitrise.io/t/flutter-build-fails-if-cache-used-and-pub-has-custom-git-repository-dependencies/10051/7 "2019-12-10T12:03:08Z")

</div>

Hello @dominik.roszkowski,  
Started investigating this issue.  
Did you recently encountered builds with this issue? It could be useful to analyze the root cause if you added the command `flutter pub cache repair` in a script step before flutter-build.  
Could you please also share the full pubspec.yaml and the list of dependencies between your corelibrary packages (it seems there are more than on packages in the repository)?  
Additionally if you can share the cache-archive state when a build failed it would be greatly useful.

---

<div class="post-metadata">

**Author:** ![laszlo.pusok](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@laszlo.pusok](https://discuss.bitrise.io/u/laszlo.pusok)\
**Post date:** [June 22, 2020, 9:45pm UTC](https://discuss.bitrise.io/t/flutter-build-fails-if-cache-used-and-pub-has-custom-git-repository-dependencies/10051/8 "2020-06-22T21:45:17Z")

</div>

Hello @dominik.roszkowski  
A pre-release version of a fix for flutter-build is available. It would be a huge help if you can help trying it out.  
It can be added by replacing `- flutter-build` with `​- git::https://github.com/bitrise-steplib/bitrise-step-flutter-build.git@fix-cache:` in a bitrise.yml workflow. Recommend creating a temporary workflow for this.

---

<div class="post-metadata">

**Author:** ![laszlo.pusok](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@laszlo.pusok](https://discuss.bitrise.io/u/laszlo.pusok)\
**Post date:** [June 24, 2020, 1:42pm UTC](https://discuss.bitrise.io/t/flutter-build-fails-if-cache-used-and-pub-has-custom-git-repository-dependencies/10051/9 "2020-06-24T13:42:13Z")

</div>

Happy to report that the flutter-build step caching issue is fixed. Released a new version 0.13.0 ([https://github.com/bitrise-steplib/bitrise-step-flutter-build/releases/tag/0.13.0](https://github.com/bitrise-steplib/bitrise-step-flutter-build/releases/tag/0.13.0)).
