skip to Main Content

Whenever I run flutter doctor in my terminal (without admin priviledges) with either C:Program FilesGitbin, “`C:Program FilesGitcmd“ or any path containing the git executable, the cmd closes instantly.

If I run the command on cmd with admin priviledges, it works.
If I run the command on cmd without any git dir added to path, it works.
I run Windows 11 and I have powershell 7.3.2 installed.

I have seen similar issues like this and others, tried the several solutions in their threads but none seems to work.

flutter doctor -v output (when run without git in Path):

[√] Flutter (Channel stable, 3.7.5, on Microsoft Windows [Version 10.0.22000.613], locale en-US)
    • Flutter version 3.7.5 on channel stable at C:flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c07f788888 (8 days ago), 2023-02-22 17:52:33 -0600
    • Engine revision 0f359063c4
    • Dart version 2.19.2
    • DevTools version 2.20.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:UsersHPAppDataLocalAndroidsdk
    • Platform android-UpsideDownCake, build-tools 33.0.2
    • Java binary at: C:Program FilesAndroidAndroid Studiojrebinjava
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:Program FilesGoogleChromeApplicationchrome.exe

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2022.1)
    • Android Studio at C:Program FilesAndroidAndroid Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)

[√] VS Code, 64-bit edition (version 1.76.0)
    • VS Code at C:Program FilesMicrosoft VS Code
    • Flutter extension version 3.60.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22000.613]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 110.0.5481.178
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 90.0.818.66

[√] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

2

Answers


  1. Chosen as BEST ANSWER

    I found the solution:

    So I noticed that after I added this line in my path

    C:flutterbin;C:Program FilesGitbin;C:WindowsSystem32
    

    as posted here by Metaller, on running flutter doctor, I got a warning:

    fatal: detected dubious ownership in repository at 'C:/Users/abc/Projects/my-awesome-project'
    'C:/Users/abc/Projects/my-awesome-project' is owned by:
            'S-1-5-32-544'
    but the current user is:
            '<my-current-user>'
    To add an exception for this directory, call:
            git config --global --add safe.directory 
    

    I ran git config --global --add safe.directory C:flutter in my powershell (make sure it's powershell - preferred you download powershell 7), removed C:flutterbin;C:Program FilesGitbin;C:WindowsSystem32 from path, added my git exe dir C:Program FilesGitbin back to path and everything started working just fine.

    If you'd like to know more about the git safe dir issue, read this article by Dennis.


  2. A more detailed explanation for those who are wondering what’s going on here.

    When you run flutter from the Windows Command Line, it invokes flutter.bat, which includes within it a bunch of tests of your environment that call EXIT 1 if they fail. This kills not just the batch file you ran, but also the the command line process you ran it from. Normally, you would use EXIT /b 1 to exit only the batch file, but the design of flutter.bat and some assumptions about how it will be used means that this results in a retry loop.

    Since there a bunch of tests in flutter.bat that could be failing, it’s unclear which of them is causing trouble, and there are a lot of answers online to the problem of flutter failing like this that suggest fixing your paths to make sure git or something else is in your path (as this not being the case triggers some earlier tests). Quwaysim’s answer corresponds to a test that fails in FLUTTER_HOMEbininternalshared.bat (which is invoked by flutter.bat) because of relatively recent changes to git that are described in the article they link.

    That test tries to run git rev-parse HEAD in your Flutter directory to get the specific version of Flutter you have installed. However, if git thinks that the repository in your Flutter directory is unsafe, it will write an error message to STDERR. Since the batch file is looking for output on STDOUT and gets none, it assumes that git is not installed, prints that message accordingly, and does a hard exit. The STDERR output includes the suggestion given, but you never get shown this message.

    Diagnosing this problem was (for me) a matter of working through the batch file that’s invoked to find out where it was actually failing. Then, by running that command myself on the commandline, I was able to see the error text and work

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search