如何修复“重击:颤动:找不到命令";错误? [英] how to fix "bash: flutter: command not found" error?
问题描述
我一直在使用VScode在Windows OS上设置所有环境变量的情况下进行抖动处理.现在,我在VScode的Git Bash终端中使用颤振升级"将颤振升级到稳定版本,现在我无法在VScode的Git Bash终端中使用颤振命令.我想知道哪里出了问题,我该如何解决?
I have been working on flutter using VScode with all environment variables set on Windows OS. Now i upgraded the flutter using "flutter upgrade" in Git Bash terminal of VScode to the stable version and now i am not able to use flutter commands in Git Bash terminal of VScode. I wonder where things could have gone wrong , how do i fix it ?
我重新验证了所有环境变量均已根据官方文档正确设置.通过Flutter控制台,Flutter命令也可以完美运行.
I re-verified that all my environment variables are set correctly according to official documentation. Also flutter commands are running perfectly through flutter console .
Ashish@DESKTOP-3JFCI3M MINGW64 ~/Desktop/Flutter Exercise/test_2
$ flutter doctor
bash: flutter: command not found
编辑:如Sam所述,对〜/.bash_profile"进行了更改,仍然出现相同的错误.我也重新检查,环境变量已经在那里设置.有什么想法我可以进一步解决吗?提前致谢 :)
同样,当执行步骤3的命令source ~/.bash_profile
时,输出为
Edit: Made changes to the "~/.bash_profile" as mentioned by Sam , still getting the same error . Also i re-checked and the environment variables are set there already. Any ideas what i could do further to fix it ? Thanks in Advance :)
Also when executed command of step no 3. source ~/.bash_profile
, output is
$ source ~/.bash_profile
bash: C:DEVLOPMENTflutterbin: command not found
bash: C:DEVLOPMENTflutterbincachedart-sdkbin: command not found```
推荐答案
以前设置的环境变量可能在某个时候被清除了,这就是为什么Flutter命令无法被识别的原因.
It's possible that the environment variable, that was previously set, got cleared at some point and that's why the Flutter command is not recognized.
无论如何,要确保Flutter位于您的配置文件中,一种方法是将其添加到~/.bash_profile
(bash配置文件)文件中的路径中. ~/.bash_profile
是每次打开Git Bash时都会执行的脚本.
In any case, one way to make sure that Flutter is in your profile is to add it to your path within your ~/.bash_profile
(bash profile) file. The ~/.bash_profile
is a script gets executed every time you open Git Bash.
向您的Bash个人资料添加Flutter
- 打开您的
~/.bash_profile
文件进行
- Open your
~/.bash_profile
file for editing:
$ nano ~/.bash_profile
- 将以下行添加到
~/.bash_profile
文件的顶部:
- Add to the top of your
~/.bash_profile
file, the following lines:
# Add Flutter to PATH
PATH=/path/to/flutter/bin:$PATH
# Add Dart to PATH
PATH=/path/to/flutter/bin/cache/dart-sdk/bin:$PATH
用Flutter安装目录的绝对路径替换
/path/to/flutter
.
- 应用更改:
$ source ~/.bash_profile
确保为非登录外壳打开Git Bash
(来源:查尔斯·达菲)
Ensuring Git Bash is opened for non-login shells
(Credit: Charles Duffy)
$ echo "source ~/.bash_profile" >> ~/.bashrc
这篇关于如何修复“重击:颤动:找不到命令";错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!