Skip to content

Flutter Version Cache Corruption with App Repository URL #178160

Description

@luksladky

Steps to reproduce

  1. Have a Flutter project that is a git repository (with a non-GitHub remote)
  2. Navigate to the project directory in terminal
  3. Run integration tests: flutter test integration_test/ -d macos
  4. After tests complete, run: flutter doctor

Note: This issue is intermittent and doesn't happen every time integration tests are run.

Expected results

flutter doctor should report the correct Flutter channel and version:

[✓] Flutter (Channel stable, 3.35.7, on macOS ...)

The Flutter installation should maintain its correct repository URL (https://github.com/flutter/flutter.git).

Actual results

flutter doctor reports an incorrect channel and version:

[!] Flutter (Channel [user-branch], 0.0.0-unknown, on macOS ...)
    ! Upstream repository https://[my-project-git-url] is not a standard remote.

Inspecting $FLUTTER_ROOT/bin/cache/flutter.version.json shows:

{
  "frameworkVersion": "0.0.0-unknown",
  "channel": "[user-branch]",
  "repositoryUrl": "https://[my-project-git-url]",
  ...
}

The repositoryUrl field contains the project's git remote URL instead of Flutter's GitHub repository URL.

Workaround: Delete the cache file and regenerate:

rm -f $FLUTTER_ROOT/bin/cache/flutter.version.json
flutter --version

Code sample

Root Cause Analysis:

In packages/flutter_tools/lib/src/version.dart (lines 632-636):

_repositoryUrl = _runGit(
  'git ls-remote --get-url $remote',
  globals.processUtils,
  flutterRoot,
);

Despite passing flutterRoot as the working directory parameter, the git command sometimes executes in the project directory context instead, causing git ls-remote --get-url origin to return the project's remote URL, which then gets incorrectly cached.

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output (when issue occurs)
$ flutter doctor -v
[!] Flutter (Channel [user-branch], 0.0.0-unknown, on macOS 15.6.1 24G90 darwin-arm64, locale en-US)
    ! Flutter version 0.0.0-unknown on channel [user-branch] at /Users/user/Documents/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      Cannot resolve current version, possibly due to local changes.
      Reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository https://bitbucket.org/user/project.git is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to https://bitbucket.org/user/project.git to dismiss this error.
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.3)
[✓] VS Code (version 1.105.1)
[✓] Connected device (2 available)
[✓] Network resources

! Doctor found issues in 1 category.
Doctor output (after workaround)
$ flutter doctor -v
[✓] Flutter (Channel stable, 3.35.7, on macOS 15.6.1 24G90 darwin-arm64, locale en-US)
    • Flutter version 3.35.7 at /Users/user/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision adc9010625 (2 weeks ago), 2025-10-21 14:16:03 -0400
    • Engine revision 035316565a
    • Dart version 3.9.2
    • DevTools version 2.48.0

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.3)
[✓] VS Code (version 1.105.1)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions