MacOS gives zsh: command not found: flutter after updating path according to Flutter Official Docs
FlutterMacosZshFlutter Problem Overview
Recently I updated Mac OS to latest Catalina and my terminal which is using zsh now start showing me following error:
zsh: command not found: flutter
It was working fine before update.
Flutter Solutions
Solution 1 - Flutter
You need to update the environment path.
-
Open terminal.
-
vim $HOME/.zshrc
-
Press "I" key for going to insert mode.
-
add the following line in the opened file:
export PATH="$PATH:/YOUR_FLUTTER_DIR/flutter/bin"
-
Press "Esc" then write
:wq!
in terminal and press enter to exit vim. -
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 ~
.
Solution 2 - Flutter
Working on macOS Catalina 10.15.5 (19F101). I have used .zprofile instead of .zhrc
-
Provide Full Disk Access to Terminal by Setting -> Security & Privacy -> Full Disk Access. Add Terminal
-
If the current terminal uses bash, change to zshell using the below command
chsh -s /bin/zsh
-
In the root directory i.e something like /Users/^YourAccount^ execute the below
touch .zprofile
vim .zprofile
-
Press I to enter insert mode. Type the below
export PATH=$PATH:/Users/^YourAccount^/^YourPath^/flutter/bin
-
Save and quit by pressing Esc, then :wq and Enter
-
Close Terminal and reopen Again. Then try executing
flutter
command
Solution 3 - Flutter
You must update your environment $PATH variable.
-
Open the file
$HOME/.zshrc
$HOME
is your home path -
add the following line in the opened file:
export PATH="$PATH:/YOUR_FLUTTER_DIR/flutter/bin"
-
save the changes and restart your terminal session.
The process is also documented here
Solution 4 - Flutter
For me removing double quotes did the fix.
Try changing
> export PATH="$PATH:[PATH TO FLUTTER]/flutter/bin"
into
> 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.
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.
Type
source .zshrc
to reload the terminal for changes
Solution 5 - Flutter
Follow these steps:
Open finder
Enter Cmd + Shift + G
Type ~
in Go to the folder popup.
Now enter Cmd + Shift + .
to show hidden files.
Open .zshrc
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
export PATH=$PATH:$HOME/FlutterDevelopment/flutter/bin
Solution 6 - Flutter
I updated from Mojave to Catalina and running Terminal, switched to the default/preferred zsh shell, from the bash shell. Then was hit with
> zsh: command not found: flutter
so, followed the advice seen elsewhere to only add the following to Users/MyUserId/.zshrc
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
Users/MyUserId/.bash_profile
to Users/MyUserId/.zshenv
Now, flutter doctor gives a clean bill of health
Solution 7 - Flutter
in android studio terminal, simply just type this command:
export PATH="/YOUR_FLUTTER_DIR/flutter/bin:$PATH"
change YOUR_FLUTTER_DIR to your actual directory
Solution 8 - Flutter
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
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
Solution 9 - Flutter
I followed URL to resolve my issue.
I simply created a .zshrc file which was not exist then added my PATH variables copied from existing .bashrc.
Solution 10 - Flutter
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.
So, I change my .zshrc file to:
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
and now it's working.
Note: I use Catalina OS v10.15.4
Solution 11 - Flutter
I had the same problem when upgrading to 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.
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.
Solution 12 - Flutter
This worked for me:
Steps:
- Type on the terminal:
open .zshrc (This opens the document in text edit)
- Add this to the end of the file:
export PATH="/Users/YOUR_USERNAME/Documents/code/tools/flutter/bin:$PATH"
- Save and close
.zshrc
- Then type:
flutter doctor
Solution 13 - Flutter
There are quite a few answers mentioned above pretty much same. I would say worth seeing into the SHELL using echo $SHELL command,
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.
N.B. Don't forget you need to add VIM before either command in the terminal app.
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
Solution 14 - Flutter
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.
You can check if .zshrc file using ls -a command