Flutter doctor script throws errors and then crashes

1,608

I found the problem. I had installed the latest version of JAVA and that has seemed to overwrite ComSpec to point to their version of cmd.exe. Bad move as I think that is what the CMD tool uses to start a child CMD. Reverted to the system32 version and it all works.

The fix:

  • Open Control PanelSystemAdvanced system settings and click on button Environment Variables.
  • If environment variable ComSpec is set to anything other than %SystemRoot%\system32\cmd.exe expanding usually to C:\Windows\system32\cmd.exe, then reset it to Windows default %SystemRoot%\system32\cmd.exe.

Mine was set to %JAVA_HOME%\bin\jcmd.exe. Thanks Oracle!!!

Share:
1,608
Phil Bousfield
Author by

Phil Bousfield

Updated on December 07, 2022

Comments

  • Phil Bousfield
    Phil Bousfield over 1 year

    When I run flutter doctor -v I get a couple of uncaught errors and then a crash.

    Output below:

    C:\Users\philb>flutter doctor -v
    'git rev-parse HEAD' is not recognized as an internal or external command,
    operable program or batch file.
    Building flutter tool...
    Running pub upgrade...
    'dir /a:l "c:\Users\philb\flutter\bin\cache\dart-sdk\" 2>nul   | find ">     bin [" 2>nul' is not recognized as an internal or external command,
    operable program or batch file.
    [√] Flutter (Channel beta, v0.11.9, on Microsoft Windows [Version 10.0.17134.407], locale en-GB)
        • Flutter version 0.11.9 at c:\Users\philb\flutter
        • Framework revision d48e6e433c (5 days ago), 2018-11-20 22:05:23 -0500
        • Engine revision 5c8147450d
        • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
    
    |CreateProcessW failed 2
    Oops; flutter has exited unexpectedly.
    Sending crash report to Google.
    Crash report sent (report ID: 7c60cb5645c44cdd)
    \CreateProcessW failed 2                                                                                               Crash report written to C:\Users\philb\flutter_02.log;
    please let us know at https://github.com/flutter/flutter/issues.
    

    Here is PATH and PATHEXT environment variables:

    Path=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\philb\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\MATLAB\R2016b\bin;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Dart\dart-sdk\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\philb\AppData\Local\Microsoft\WindowsApps;c:\users\philb\flutter\bin
    

    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

    The CMD window can find git

    C:\Users\philb>where git
    C:\Program Files\Git\cmd\git.exe
    

    Just for S&G I put some debug in flutter.bat and PATH and PATHEXT are OK just before it invokes git. The only thing done to PATH is that the flutter.bat script adds the location of another version of "git" (mingit) to the PATH but that doesn't seem to matter. Even if it uses that version the same error results. The script invokes git via a for /f loop/

    The script code in flutter.bat looks like this:

    PUSHD "%flutter_root%"
    
      FOR /f %%r IN ('git rev-parse HEAD') DO SET revision=%%r
    
    POPD
    

    I checked and flutter_root = /users/phil/flutter/bin

    I noticed that the flutter directory is read only after extracting. But I do have "all control" as far as I know. I tried to change that but after a complex session as local admin I failed to clear the read only flag but not sure if that is a red herring! I can try again if someone has a thought about what's up!

  • Shriki
    Shriki about 2 years
    Thank you so much.