简体   繁体   English

flutter 医生在命令提示符或 PowerShell window 上都不起作用?

[英]flutter doctor doesn't work on neither Command Prompt or PowerShell window?

flutter doctor doesn't work on either Command Prompt or PowerShell window? flutter doctor在命令提示符或 PowerShell window 上都不起作用? I have been trying to install flutter on windows.我一直在尝试在 windows 上安装 flutter。 I have cloned the Flutter SDK as mentioned in the tutorial.如教程中所述,我已经克隆了 Flutter SDK。 I have added git and the flutter to my path.我已将 git 和 flutter 添加到我的路径中。 But still when I try to run the flutter doctor the command prompt reply with this:但是当我尝试运行flutter doctor时,命令提示符回复如下:

'where' is not recognized as an internal or external command operable program or batch file.
Error: Unable to find git in your path

在此处输入图像描述

check the cmd image you will see exactly the problem检查 cmd 图像你会看到问题

1) Make sure that the environment variables are set correctly, 1)确保环境变量设置正确,

  • Go to “Control Panel > User Accounts > User Accounts > Change my environment variables”转到“控制面板>用户帐户>用户帐户>更改我的环境变量”

  • Under “User variables” check if there is an entry called “Path”:在“用户变量”下检查是否有一个名为“路径”的条目:

    • If the entry does exist, append the full path to flutter\\bin using ;如果该条目确实存在,请使用;将完整路径附加到flutter\\bin; as a separator from existing values.作为现有值的分隔符。

    • If the entry does not exist, create a new user variable named Path with the full path to flutter\\bin as its value.如果该条目不存在,则创建一个名为 Path 的新用户变量,并将flutter\\bin的完整路径作为其值。

2) Reboot your computer 2)重启你的电脑

Once both above steps are done, run flutter doctor完成上述两个步骤后,运行flutter doctor

Note: Run this command in either a Command Prompt or PowerShell window.注意:在命令提示符或 PowerShell 窗口中运行此命令。 Currently, Flutter does not support third-party shells like Git Bash.目前,Flutter 不支持 Git Bash 等第三方 shell。 (Source: Flutter Documentation) (来源:Flutter 文档)

to run flutter from the command prompt on your windows system it requires three things要从 Windows 系统上的命令提示符运行 flutter,它需要三件事

  1. path to the bin folder of downloaded flutter sdk I have downloaded and saved the sdk in my documents so for me path will be 下载的 flutter sdk的 bin 文件夹的路径我已经下载并将 sdk 保存在我的文档中,所以对我来说路径将是

C:\\Users\\mahesh_2\\Documents\\flutter_windows_v0.11.9-beta\\flutter\\bin

  1. where.exe located at C:\\Windows\\System32 where.exe位于C:\\Windows\\System32

Note:you need to download git from here if you dont find path in step 3注意:如果在步骤 3 中没有找到路径,则需要从这里下载git

  1. git-cmd.exe located in C:\\Program Files\\Git\\git-cmd.exe git-cmd.exe位于C:\\Program Files\\Git\\git-cmd.exe

so to simply add these three paths to your environment variables go to system environment variables with variable name as Path所以只需将这三个路径添加到您的环境变量中,转到变量名为Path系统环境变量

and value as价值为

C:\\Windows\\System32;C:\\Program Files\\Git\\git-cmd.exe;C:\\Users\\mahesh_2\\Documents\\flutter_windows_v0.11.9-beta\\flutter\\bin

在此处输入图片说明

restart the command prompt and try running flutter and Voila!重新启动命令提示符并尝试运行 flutter 和Voila! you should get something like this你应该得到这样的东西

在此处输入图片说明

I had the exact same issue, and by following the solution given here , I was able to resolve this.我遇到了完全相同的问题,按照此处给出的解决方案,我能够解决此问题。

The issue was C:\\Windows\\System32\\ was missing from my PATH variable.问题是我的 PATH 变量中缺少C:\\Windows\\System32\\ So, to resolve it just follow the below steps:因此,要解决它,只需按照以下步骤操作:

  1. In Search, search for and then select: System (Control Panel)在搜索中,搜索并选择:系统(控制面板)

  2. Click the Advanced system settings link.单击高级系统设置链接。

  3. Click Environment Variables .单击环境变量 In the section System Variables, find the PATH environment variable and select it.在 System Variables 部分,找到PATH环境变量并选择它。 Click Edit .单击编辑

  4. In the Edit System Variable window, add C:\\Windows\\System32 separated by a ;在 Edit System Variable 窗口中,添加C:\\Windows\\System32 ,以;分隔; . . Click OK .单击“确定” Close all remaining windows by clicking OK.单击确定关闭所有剩余的窗口。

  5. Restart your computer.重新启动计算机。

Now run flutter doctor现在跑flutter doctor

Solving above issue解决上述问题

Set the three variable path设置三个变量路径

  • First Flutter path (Mainly in c drive)第一个Flutter路径(主要在c盘)

    C:\\src\\flutter\\bin C:\\src\\flutter\\bin

  • Second GIT Path第二条 GIT 路径

    C:\\Program Files\\Git\\cmd C:\\Program Files\\Git\\cmd

  • Third System32 path第三个 System32 路径

    C:\\Windows\\System32 C:\\Windows\\System32

Use Window command Prompt if you working with Window , Restart the command prompt it will work properly.如果您使用 Window 命令提示符,请使用 Window 命令提示符,重新启动命令提示符它将正常工作。

Run Command运行命令

flutter upgrade颤振升级

有同样的问题,并通过在环境变量中加入一定扑PATH ...系统变量中解决它,当你“编辑系统环境变量。编辑上盒所谓的‘用户变量’,没有解决问题对我来说。

Simply check all the Environmental variables ... these are present in path Variable or not, in case of Flutter只需检查所有环境变量......这些是否存在于路径变量中,以防万一

C:\Windows\System32;
C:\Program Files\Git\cmd;
C:\Program Files\Java\jdk1.8.0_221\bin;
D:\flutter_windows_v1.7.8+hotfix.4-stable\flutter\bin\

System32 file is important for git. System32 文件对 git 很重要。 please check is it present or not.请检查它是否存在。

There are two mistakes to be avoided:有两个错误要避免:

  1. Add it to the System variables Path, not the user variables path将其添加到系统变量路径,而不是用户变量路径

  2. In the Windows 10 Interface do not mistake the new variable for the solution to add your path to the Path-variable.在 Windows 10 界面中,不要将新变量误认为是将您的路径添加到路径变量的解决方案。 In most cases there should alrady be a variable named Path (otherwise create one) which contains all paths and you have to append your path to flutter/bin to this Path-variable.在大多数情况下,应该有一个名为 Path 的变量(否则创建一个),其中包含所有路径,并且您必须将您的 flutter/bin 路径附加到此 Path 变量。

I have same issue.我有同样的问题。 (I already add env variable n works fine last week) the problem is my antivirus delete flutter.bat in flutter\\bin. (我上周已经添加了 env 变量 n 工作正常)问题是我的防病毒软件删除了 flutter\\bin 中的 flutter.bat。

i fix this, after redownload flutter.bat or redownload whole flutter.我在重新下载 flutter.bat 或重新下载整个 flutter 后解决了这个问题。

I just removed the existing path and added a new one to make it work.我刚刚删除了现有路径并添加了一个新路径以使其工作。

  1. Delete existing Path删除现有路径
  2. Create a new user variable named Path with the full path to flutter\\bin as its value创建一个名为Path的新用户变量,并将 flutter\\bin 的完整路径作为其值
  3. Set the three variable path:设置三个变量路径:

    C:\\Windows\\System32;C:\\Program Files\\Git\\git-cmd.exe;D:\\flutter\\flutter\\bin C:\\Windows\\System32;C:\\Program Files\\Git\\git-cmd.exe;D:\\flutter\\flutter\\bin

D:\\flutter\\flutter\\bin should be replaced with the path to your drive (the placed where you extracted Flutter zip file D:\\flutter\\flutter\\bin应该替换为你的驱动器的路径(你解压 Flutter zip 文件的位置)

Close and reopen the console for these changes to take effect.关闭并重新打开控制台以使这些更改生效。

First of all where.exe command is located inside C:windows\\System32, so go to首先where.exe命令位于C:windows\\System32里面,所以去

  1. Edit the System Environment Setting编辑系统环境设置
  2. Click Environment and edit,单击环境并编辑,
  3. Then inside 'Path' add C:windows\\System32 separated by ;然后在 'Path' 中添加 C:windows\\System32 ,以 ; 分隔。
  4. Finally add C:\\Program Files\\Git\\git-cmd.exe click OK最后添加 C:\\Program Files\\Git\\git-cmd.exe 点击 OK

Now restart your cmd again.现在再次重启你的cmd

If your working in Android Studio , you will find it on the如果您在Android Studio工作,您会在

Tools -> Flutter -> Flutter Doctor Tools -> Flutter -> Flutter Doctor

Running flutter doctor on the cmd is not recognizable as internal or external command.在 cmd 上运行 flutter doctor 无法识别为内部或外部命令。

颤振

But on Android Studio Terminal , it run just fine.但是在 Android Studio Terminal ,它运行得很好。

扑医生


PS - If you use Android Studio as your IDE, don't forget to install the Flutter Plugin and Dart Plugin. PS - 如果您使用 Android Studio 作为 IDE,请不要忘记安装Flutter插件和Dart插件。

I was also stuck in the same problem where I was running flutter command on Window default command prompt.我也遇到了同样的问题,我在 Window 默认命令提示符下运行flutter命令。 Although I have already added the C:\\src\\flutter\\bin path in User Environment Variables .虽然我已经在User Environment Variables 中添加了C:\\src\\flutter\\bin路径。 The solution that works for me is to add C:\\Windows\\System32\\ into the Path variable in User Environment Variables .对我C:\\Windows\\System32\\的解决方案是将C:\\Windows\\System32\\User Environment VariablesPath变量中。 Once you have done this restart your system and run flutter command on default Command Prompt.完成此操作后,重新启动系统并在默认命令提示符下运行flutter命令。

Hope this will help you out.希望这会帮助你。

Remove spaces before and after each path in your Environment Variables !删除环境变量中每个路径前后的空格

// incorrect value
C:\src\flutter\bin; C:\Program Files\Git\git-cmd.exe; C:\Windows\System32\

// correct value
C:\src\flutter\bin;C:\Program Files\Git\git-cmd.exe;C:\Windows\System32\

It didn't work for me either.它对我也不起作用。 But when I installed what is written here, I rebooted my computer and everything worked for me.但是当我安装了这里写的东西时,我重新启动了我的电脑,一切都对我有用。 在此处输入图片说明

如果您像我一样将 flutter 添加到用户环境中不起作用,您实际上可以通过将flutter替换为 flutter.bat 文件的路径来运行命令,如下所示: C:\\fluttersdk\\flutter\\bin\\flutter.bat doctor这有效以同样的方式,如果您正在运行flutter build apk它最终会像这样: C:\\fluttersdk\\flutter\\bin\\flutter.bat build apk作为命令。

Just adding my two cents.只需加上我的两分钱。 I had same problem and after trying everything i read, i eventually just used "echo %path%" in the command line and saw that the path of flutter contains illegal character.我遇到了同样的问题,在尝试了我读过的所有内容后,我最终只是在命令行中使用了“echo %path%”,发现 flutter 的路径包含非法字符。 After deleting flutter entry in PATH and typing it again manually instead of copying it, it is finally working.删除PATH中的flutter条目并再次手动输入而不是复制它后,它终于可以工作了。 Just in case it can help someone.以防万一它可以帮助某人。

在此处输入图片说明

If it happened to you like it happened to me, you probably went to add flutter\\bin to the environment variables by editing the Path system variable.如果它发生在你身上,就像发生在我身上一样,你可能会通过编辑Path系统变量将flutter\\bin添加到环境变量中。

You then proceeded to press the Browse button, and selected your desired path.然后您继续按Browse按钮,并选择您想要的路径。

The part you didn't expect was that it actually overwrote the %SYSTEMROOT%\\System32 entry, which is the first path in the list, and the path which becomes highlighted by default when you open that edit window.您没想到的部分是它实际上覆盖了%SYSTEMROOT%\\System32条目,这是列表中的第一个路径,并且在您打开该编辑窗口时默认突出显示该路径。

If this is the case for you, simply press the New button, and add %SYSTEMROOT%\\System32 back into the Path variable, which should make where.exe available again.如果是这种情况,只需按下“ New按钮,然后将%SYSTEMROOT%\\System32添加回Path变量,这将使where.exe再次可用。

The thing to note here is that the Browse button in the Path variables edit window, will overwrite the highlighted path with the newly selected path, so it is important to make sure none of the existing paths are highlighted when using it.这里要注意的是, Path变量编辑窗口中的Browse按钮将用新选择的路径覆盖突出显示的路径,因此确保在使用时没有突出显示现有路径很重要。

I really see a big mess here;我真的看到这里乱七八糟; however the solution is very simple.然而,解决方案非常简单。 Even no restart needed.甚至不需要重启。

To my case I saved the flutter folder in my account's source folder and I appended this value in the PATH entry;就我而言,我将 flutter 文件夹保存在我帐户的源文件夹中,并将此值附加到 PATH 条目中;

%USERPROFILE%\source\flutter\bin

Note: I only had one value and it was for Microsoft WindowsApps (;注意:我只有一个值,它用于 Microsoft WindowsApps (;

Explanation说明

Now, we all know that we need to append "the full path to flutter\\bin" in the PATH entry or create a new one if it doesn't exist.现在,我们都知道我们需要在 PATH 条目中附加“flutter\\bin 的完整路径”,或者如果它不存在则创建一个新路径。 However, Windows users have different profile folders thus our case for the full path .但是,Windows 用户有不同的配置文件文件夹,因此我们使用完整路径 So to solve this common problem whatever was the typical path for the user's profile folder, we can use %USERPROFILE% value which is a Constant special item ID list ( CSIDL ).因此,无论用户配置文件文件夹的典型路径是什么,为了解决这个常见问题,我们都可以使用%USERPROFILE%值,它是一个常量特殊项目 ID 列表 ( CSIDL )。 See Recognized Environment Variables查看识别的环境变量

Constant special item ID list (CSIDL) values provide a way to identify folders that applications use frequently but may not have the same name or location on any given computer.常量特殊项目 ID 列表 (CSIDL) 值提供了一种方法来标识应用程序经常使用但在任何给定计算机上可能不具有相同名称或位置的文件夹。

So if you saved the Flutter folder, like me, in the user's profile folder, Just copy %USERPROFILE% and paste it before the flutter's bin folder directory in the PATH entry and then append all to the existing values using ;因此,如果您像我一样将 Flutter 文件夹保存在用户的配置文件文件夹中,只需复制%USERPROFILE%并将其粘贴到 PATH 条目中flutter 的 bin 文件夹目录之前,然后使用; as a separator or similarly click the New button on the right side of the panel and paste it.作为分隔符或类似地单击面板右侧的新建按钮并粘贴它。

I tried setting absolute paths for 'System32' and 'PowerShell' but it didn't work.我尝试为“System32”和“PowerShell”设置绝对路径,但没有用。 Finally, it was solved after setting the path as follows.最后按照如下设置路径后解决了。

在此处输入图片说明

I also encountered that when I was installing flutter .我在安装flutter时也遇到过。

Add those to System variables (not user variables), besides flutter itself:将这些添加到系统变量(不是用户变量)中,除了 flutter 本身:

C:\Flutter\flutter_windows_2.2.1-stable\flutter\bin

make sure you have System32, Git and PowerShell确保你有 System32、Git 和 PowerShell

C:\Program Files\Git\cmd
C:\Program Files\Git\bin
C:\Windows\System32
C:\Windows\System32\WindowsPowerShell\v1.0

Flutter doctor will also complain about Java so make sure you install and add the java sdk to path as well: Flutter doctor 也会抱怨 Java,因此请确保您也安装 Java sdk 并将其添加到路径中:

C:\Program Files\Java\jdk-12.0.2\bin

The problem on my side was that PowerShell was missing from path .我这边的问题是path中缺少 PowerShell。

In My case, I type command flutter pub get in terminal it works for me就我而言,我在终端中输入命令 flutter pub get 它对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 命令提示符正确执行此操作,但 Powershell 没有? - Command Prompt executes this correctly but Powershell doesn't? 为什么有时在 PowerShell 的“python -c [command]”(以及命令提示符)中使用单引号将命令括起来时不起作用? - Why doesn't it work sometimes when using single quotes to surround the command in `python -c [command]` in PowerShell (and in command prompt as well)? 使用字符串执行命令在powershell中不起作用 - Executing a command with string doesn't work in powershell Chef Powershell命令不起作用 - chef powershell command doesn't work dotnet 命令在 powershell 中不起作用 - dotnet command doesn't work from powershell powershell 命令成批处理 - 它不起作用 - powershell command into batch - it doesn't work workon 命令在 Windows PowerShell 中无法激活 virtualenv - workon command doesn't work in Windows PowerShell to activate virtualenv Powershell Docker 命令不像蝙蝠文件那样工作 - Powershell Docker Command Doesn't Work Like Bat File Powershell 命令“Get-DistributionGroup”不起作用 - The Powershell Command “Get-DistributionGroup” doesn't work echo命令不适用于Windows 10中的PowerShell - echo command doesn't work with PowerShell in Windows 10
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM