运行flutter doctor -v
时遇到一些未捕获的错误,然后崩溃。
以下输出:
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.
这里是PATH
和PATHEXT
环境变量:
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
CMD窗口可以找到git
C:\Users\philb>where git
C:\Program Files\Git\cmd\git.exe
就S&G而言,我在flutter.bat
中进行了一些调试,并且PATH
和PATHEXT
在调用git
之前就可以了。对PATH
所做的唯一一件事就是flutter.bat
脚本将另一版本的“ git”(mingit)的位置添加到PATH
中,但这似乎无关紧要。即使使用该版本,也会产生相同的错误。脚本通过git
循环/
for /f
flutter.bat中的脚本代码如下:
PUSHD "%flutter_root%"
FOR /f %%r IN ('git rev-parse HEAD') DO SET revision=%%r
POPD
我检查并flutter_root = /users/phil/flutter/bin
我注意到只有在解压缩之后才能读取flutter目录。但据我所知,我确实拥有“全部控制权”。我试图进行更改,但是在以本地管理员的身份进行了复杂的会话后,我无法清除只读标志,但不确定是否是红色鲱鱼!如果有人对发生的事情有想法,我可以重试!
答案 0 :(得分:1)
我发现了问题。我安装了最新版本的 JAVA ,它似乎覆盖了ComSpec
,以指向其cmd.exe
的版本。我认为这是CMD工具用来启动子级CMD的错误动作。恢复为system32版本,一切正常。
解决方法:
ComSpec
设置为除%SystemRoot%\system32\cmd.exe
以外的其他值,通常扩展为C:\Windows\system32\cmd.exe
,则将其重置为Windows默认值%SystemRoot%\system32\cmd.exe
。我的被设置为%JAVA_HOME%\bin\jcmd.exe
。谢谢甲骨文!