gpt4 book ai didi

After upgrade MacOS terminal showing: zsh: command not found: flutter(升级MacOS终端后显示:zsh:未找到命令:颤动)

转载 作者:bug小助手 更新时间:2023-10-25 23:06:11 27 4
gpt4 key购买 nike



Recently I updated Mac OS to latest Catalina. Now when entering a flutter command like the following,

最近,我把Mac OS更新到了最新的Catalina。现在,当输入如下所示的颤动命令时,


flutter --version

my terminal (which is using zsh) shows me following error:

我的终端(使用zsh)显示以下错误:


zsh: command not found: flutter

How do I reinstate the path to allow flutter commands from any directory?

如何恢复路径以允许来自任何目录的颤振命令?


更多回答

first answer ok, but for who does not like vim here is other way for Ubuntu users: 1. open terminal ``` ctrl + alt + t ``` 2. `` nano $HOME/.zshrc ``` 3. at the end of the file add the following line ( please replace [flutter_dir] with your director ``` export PATH=$PATH:[flutter_dir]/flutter/bin ``` 4. exit -> save ``` ctrl + x ``` 5. source ~/.zshrc

首先回答OK,但对于不喜欢VIM的Ubuntu用户来说,这里是另一种方式:1.打开终端`ctrl+alt+t`2.``Nano$HOME/.zshc`3.在文件末尾添加以下行(请将[fltter_dir]替换为您的导演`导出路径=$Path:[fltter_dir]/fltter/bin``4.退出->保存`ctrl+x``5.source~/.zshc

This question is clearly relevant to software tools primarily used by programmers. The fact that as of today it has 90 upvotes and that the most-upvoted answer has 305 upvotes shows how many people have found this question useful.

这个问题显然与程序员主要使用的软件工具有关。截至今天,它有90个赞成票,最受欢迎的答案有305个赞成票,这表明有多少人认为这个问题有用。

In my case, my problem was the relative path to the flutter folder. I changed it to the absolute path and it was all fine.

在我的例子中,我的问题是Ffltter文件夹的相对路径。我把它改成了绝对路径,一切都很好。

This question shouldn't have been closed.

这个问题本不应该结束。

This question shouldn't have been closed

这个问题不应该结束

优秀答案推荐

You need to update the environment path.

您需要更新环境路径。



  1. Open terminal.



  2. vim $HOME/.zshrc



  3. Press "I" key for going to insert mode.



  4. add the following line in the opened file:


    export PATH="$PATH:/YOUR_FLUTTER_DIR/flutter/bin"



  5. Press "Esc" then write :wq! in terminal and press enter to exit vim.



  6. Reopen the terminal and check "flutter doctor"




If this solution did not work, remove the double quote from path or use the full path explicitly instead of ~.

如果此解决方案不起作用,请删除PATH中的双引号或显式使用完整路径而不是~。



Working on macOS Catalina 10.15.5 (19F101).
I have used .zprofile instead of .zhrc

使用MacOS Catalina 10.15.5(19F101)。我使用的是.zprofile,而不是.zhrc



  1. Provide Full Disk Access to Terminal by
    Setting -> Security & Privacy -> Full Disk Access. Add Terminal



  2. If the current terminal uses bash, change to zshell using the below command


    chsh -s /bin/zsh



  3. In the root directory i.e something like /Users/^YourAccount^ execute the below


    touch .zprofile


    vim .zprofile



  4. Press I to enter insert mode. Type the below


    export PATH=$PATH:/Users/^YourAccount^/^YourPath^/flutter/bin



  5. Save and quit by pressing Esc, then :wq and Enter



  6. Close Terminal and reopen Again. Then try executing flutter command





For me removing double quotes did the fix.

对我来说,去掉双引号解决了问题。


Try changing

尝试更改



export PATH="$PATH:[PATH TO FLUTTER]/flutter/bin"



into

vt.进入,进入



export PATH=$PATH:[PATH TO FLUTTER]/flutter/bin



adding few more steps for easiness:

增加了几个简单的步骤:


Open terminal.

开放终端。


vim $HOME/.zshrc

Press "I" to open insert mode.

按“I”打开插入模式。


add the following line in the opened file:

在打开的文件中添加以下行:


export PATH=$PATH:[PATH TO FLUTTER]/flutter/bin (remember I don't have double quotes here)

Press "Esc" then type :wq in terminal to exit edit mode.

按“Esc”键,然后在终端中键入:wq退出编辑模式。


Type
source .zshrc to reload the terminal for changes

键入Source.zshc以重新加载终端以进行更改



You must update your environment $PATH variable.

您必须更新环境$PATH变量。



1) Open the file $HOME/.zshrc $HOME is your home path

1)打开文件$HOME/.zshc$HOME是您的主路径



2) add the following line in the opened file:

2)在打开的文件中添加以下行:



export PATH="$PATH:/YOUR_FLUTTER_DIR/flutter/bin"


3) save the changes and restart your terminal session.

3)保存更改并重新启动终端会话。



The process is also documented here

此处还记录了该过程



Follow these steps:

请执行以下步骤:


Open finder
Enter Cmd + Shift + G

打开查找器输入Cmd+Shift+G


Type ~ in Go to the folder popup.

在弹出的文件夹中键入~。


Now enter Cmd + Shift + . to show hidden files.

现在输入Cmd+Shift+。要显示隐藏文件,请执行以下操作。


Open .zshrc

打开.zshc


Add this line

添加此行


export PATH="$PATH:/YOUR_FLUTTER_DIR/flutter/bin"

Replace this /YOUR_FLUTTER_DIR with the path to your flutter directory.
In my mac, the path is

将此/YOUR_FUTTH_DIR替换为颤振目录的路径。在我的Mac上,路径是


export PATH=$PATH:$HOME/FlutterDevelopment/flutter/bin


in android studio terminal, simply just type this command:

在Android演播室终端,只需输入以下命令:


export PATH="/YOUR_FLUTTER_DIR/flutter/bin:$PATH"

change YOUR_FLUTTER_DIR to your actual directory

将YOUR_FLATTER_DIR更改为实际目录



I updated from Mojave to Catalina and running Terminal, switched to the default/preferred zsh shell, from the bash shell.
Then was hit with

我从Mojave更新到Catalina,并运行终端,从bash外壳切换到默认/首选的zsh外壳。然后被打了一顿




zsh: command not found: flutter




so, followed the advice seen elsewhere to only add the following to Users/MyUserId/.zshrc

因此,按照在别处看到的建议,只将以下内容添加到USERS/MyUserID/.zshc



export PATH="$PATH:/YOUR_FLUTTER_DIR/flutter/bin"


echo $PATH showed that /Users/MyUserId/flutter/bin was now one of the configured PATHs.
However, I couldn't get "flutter doctor" to work but came across a post on jelliesgame.com which suggested copying

ECHO$PATH显示,/USERS/MyUserID/Ffltter/bin现在是配置的路径之一。然而,我没能让《扑翼医生》去上班,但我在jelliesgame.com上看到了一篇帖子,建议我抄袭



Users/MyUserId/.bash_profile to Users/MyUserId/.zshenv

USERS/MyUserID/.bash_PROFILE TO USERS/MyUserID/.zshenv



Now, flutter doctor gives a clean bill of health

现在,扑动医生给出了一份干净的健康证明



This worked for me:

这对我来说很管用:


Steps:

步骤:



  1. Type on the terminal:
    open .zshrc (This opens the document in text edit)


  2. Add this to the end of the file:
    export PATH="/Users/YOUR_USERNAME/Documents/code/tools/flutter/bin:$PATH"


  3. Save and close .zshrc

  4. Then type:
    flutter doctor




Had the same issue and just realized that I forgot to add the close quote

有同样的问题,只是意识到我忘了添加右引号



So the correct way is to add to .zshrc by typing vim ~/.zshrc

因此,正确的方法是通过键入vim~/.zshc来添加到.zshc



PATH="$PATH:$HOME/Flutter/flutter/bin"


or



export PATH="$PATH:/YOUR_FLUTTER_DIR/flutter/bin"


then run source ~/.zshrc or just open a new terminal window

然后运行~/.zshrc源文件或打开一个新的终端窗口



I tried installing flutter on my MAC according to the advice here, but it still doesn't work, after searching for it I found an article here.

我试着按照这里的建议在我的Mac上安装Fflight,但仍然不起作用,搜索后我发现了一篇文章在这里。



So, I change my .zshrc file to:

因此,我将我的.zshc文件更改为:



export PATH="$PATH:/Users/YOUR_PROVILE_NAME/YOUR_DEVELOPMENT_FOLDER/flutter/bin"


Change YOUR_PROVILE_NAME to your name profile, also YOUR_DEVELOPMENT_FOLDER to your development folder for flutter

将您的_provile_name更改为您的姓名配置文件,并将您的_Development_Folders更改为您的Ffltter的开发文件夹



and now it's working.

现在它起作用了。



Note:
I use Catalina OS v10.15.4

注意:我使用的是Catalina OS v10.15.4



I followed URL to resolve my issue.

我跟随URL解决了我的问题。



I simply created a .zshrc file which was not exist then added my PATH variables copied from existing .bashrc.

我只是创建了一个不存在的.zshrc文件,然后添加了从现有.bashrc复制的PATH变量。



I had the same problem when upgrading to mac Catalina 10.15.4:

我在升级到Mac Catalina 10.15.4时遇到了同样的问题:



After many days of research, I have achieved success. Here are the steps I did:

经过多天的研究,我取得了成功。以下是我所做的步骤:



First, open the terminal on your mac.

首先,在你的Mac上打开终端。



Next, use the command

接下来,使用命令



 cat .bash_profile


and copy the content.

并复制内容。



Then type this command into the terminal:

然后在终端中键入以下命令:



nano $ HOME / .zshrc


and paste the content just copied above into. Save then type

然后把上面复制的内容粘贴到。保存然后键入



source $ HOME / .zshrc


to refresh this file. Next type

以刷新此文件。下一个类型



echo $ PATH


to see if the content has been updated. If successful type

查看内容是否已更新。如果成功,请键入



flutter --version


and you will see the result.

你会看到结果的。



There are quite a few answers mentioned above pretty much same. I would say worth seeing into the SHELL using echo $SHELL command,

上面提到的相当多的答案基本相同。我认为值得使用ECHO$SHELL命令深入了解外壳,


If you’re using Bash, edit $HOME/.bash_profile or $HOME/.bashrc. If you’re using Z shell, edit $HOME/.zshrc. If you’re using a different shell, the file path and filename will be different on your machine.

如果您正在使用Bash,请编辑$HOME/.bash_PROFILE或$HOME/.bashrc。如果您使用的是ZShell,请编辑$HOME/.zshc。如果您使用的是不同的外壳程序,则您的计算机上的文件路径和文件名也会不同。


N.B. Don't forget you need to add VIM before either command in the terminal app.

注意:别忘了,你需要在终端应用程序中的任一命令之前添加vim。


For further details, click the link Update your path, and look into the section Update your Path. I hope it would help many especially new comers to MAC OS. Cheers

有关更多详细信息,请单击链接更新您的路径,然后查看更新您的路径部分。我希望它能帮助很多新手,特别是新手。干杯



For me .zshrc worked instead of .zprofile. I believe this is because I had created .zshrc earlier and now when I tried creating .zprofile, it was looking into .zshrc file.

对我来说,.zshc代替.zprofile起作用。我相信这是因为我之前创建了.zshc,而现在当我尝试创建.zprofile时,它正在查看.zshc文件。


You can check if .zshrc file using ls -a command

您可以使用ls-a命令检查.zshc文件



For me moving the flutter folder to document page and setting the new path solved the issue

对于我来说,将Ffltter文件夹移动到文档页面并设置新路径解决了问题


before-> /Users/kunalkalwar/Desktop/AndroidProjects/Softwares/flutter

之前->/Users/kunalkalwar/Desktop/AndroidProjects/Softwares/flutter


after-> /Users/kunalkalwar/Documents/flutter

之后->/用户/kunalicwar/文档/扑图


更多回答

Thanks. I actually used the format of PATH in my system "export PATH=/FLUTTER_DIR/flutter/bin:$PATH" and it works. the $PATH proceeds after the flutter dir

谢谢。我实际上在我的系统中使用了PATH的格式“EXPORT PATH=/FUTTH_DIR/FUTTH/BIN:$PATH”,并且它起作用了。$路径在颤振方向之后继续

is the "I" key the pipe? Or capital "I" as in Indigo or lower case "l" as in lima?

“i”键是烟斗的钥匙吗?还是大写的“i”,如Indigo,或小写的“L”,如Lima?

I need to remove double quote from path to get it work..

我需要从路径中删除双引号才能使其正常工作。

This worked wonders! Thanks! I already had an anaconda block added automatically by the installation, I wrote export PATH=$PATH:~/development/flutter/bin above it and now both work fine.

这真是个奇迹!谢谢!我已经通过安装自动添加了一个蟒蛇块,我在它上面写了EXPORT PATH=$PATH:~/Development/Ffltter/bin,现在两者都工作得很好。

Removing double quotes was what was needed for me. Thanks!

删除双引号是我所需要的。谢谢!

First recommendation "Provide Full Disk Access to Terminal by Setting -> Security & Privacy -> Full Disk Access. Add Terminal" works for me. Tnx.

第一个建议“通过设置->安全与隐私->全盘访问终端来提供对终端的全盘访问。添加终端”适用于我。Tnx。

Worked for me as well ! Thanks for help

对我也有用!多谢帮忙

Why we are giving full disk access to terminal ? @iamnagaky

为什么我们要给终端提供完整的磁盘访问权限?@iamnagaky

As because we are using terminal to execute the flutter commands. I am not very sure of the specifics.

因为我们正在使用终端执行颤振命令。我不是很确定具体情况。

Providing full disk access worked for me. I did all the stuff given in the above answer.

提供完整的磁盘访问对我来说很管用。我做了上面答案中给出的所有事情。

source .zshrc to reload the terminal worked for me. Thanks!

源.zshc重新加载终端对我来说很有效。谢谢!

It's weird, but it works for me. Any explanation why removing quotes helps?

这很奇怪,但对我来说很管用。有什么解释为什么去掉引号有帮助吗?

for Ubuntu user's please use source ~/.zshrc instead of source .zshrc

对于Ubuntu用户,请使用源~/.zshc而不是源.zshc

For others wondering...(stupid me, but) the 'restart terminal session' did the trick for me. (do the same in Android Studio of Visual Studio Code!)

对于其他想知道的人来说……(愚蠢的我,但是)‘重启终端会话’对我来说起到了作用。(在Visual Studio代码的Android Studio中执行相同的操作!)

Same here. The post important part "restart your terminal session." Or you could spend extra 1 hour.

这里也一样。POST的重要部分“重启您的终端会话”。或者你可以多花一个小时。

Any explanation why removing quotes helps?

有什么解释为什么去掉引号有帮助吗?

@anber: Bcz it contains a variable $PATH, which would resolve to actual path localtion. if you still want to use "" then replace $PATH with actual path. Hope it helps.

@Anber:bcz它包含一个变量$PATH,它将解析为实际的路径位置。如果您仍想使用“”,则将$PATH替换为实际路径。希望能有所帮助。

I hate to admit it, but it wasn't working for me and your answer made me realize I left off the leading "/" in my path... doh!

我不想承认这一点,但这对我不起作用,你的回答让我意识到我在前进的道路上遗漏了前导“/”。多!

double quotes not needed in big Sur

大行情中不需要双引号

this is because some other exports have messed your zsh profile. Who experience similar issues - check if you have messed lines like 'export PATH=/opt/homebrew/bin$PATH' and change them to export PATH=/opt/homebrew/bin/:$PATH - notice : symbol before PATH

这是因为其他一些导出已经扰乱了您的zsh配置文件。谁遇到了类似的问题-检查您是否有乱七八糟的行,如‘EXPORT PATH=/opt/HOME BREW/bin$PATH’,并将它们更改为EXPORT PATH=/opt/HOME BREW/bin/:$PATH-注意:路径前有符号

This did the trick for me as well, thanks! I'm on macOS Big Sur 11.0

这对我也起到了作用,谢谢!我在MacOS Big Sur 11.0上

please provide the url's content, as URL's may expire

请提供URL的内容,因为URL可能会过期

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com