If the entry does not exist, create a new user variable named Path with the full path to flutter\bin as its value. to Solve Command Not Found in Flutter First, download the latest SDK from the flutter download page. Now to run flutter in the windows console you need to update your PATH environment variable.
flutter : The term 'flutter' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. This error happens when Flutter is not installed correctly in your OS.
You need to correctly set up your Flutter path.
From macOS install - Update your path:
Determine the directory where you placed the Flutter SDK. You will need this in Step 3.
Open (or create) $HOME/.bash_profile
. You can do that by using terminal text editor by going in terminal and typing nano ~/.bash_profile
macOS v10.15 (Catalina) uses the Z shell by default, so edit $file HOME/.zshrc.
If you are using a different shell, the file path and filename will be different on your machine.
Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY]
to be the path where you cloned Flutter’s Git repository is:
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
For example:
export PATH=~/Documents/flutter/bin:$PATH
Press Ctrl + X and when it asks you to save the file, choose Yes
Run source $HOME/.bash_profile
to refresh the current window or restart the terminal
Verify that the flutter/bin
directory is now in your PATH by running:
echo $PATH
Notice that [PATH_TO_FLUTTER_GIT_DIRECTORY]
is where you installed Flutter SDK, not the location of your app
Instead of nano, you can use any text editor to edit file ~/.bash_profile
.
For zsh:
nano ~/.zshrc
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
source ~/.zshrc
flutter doctor -v
For example : if flutter in your machine has been installed under [your_username]/Developer/flutter
export PATH=Developer/flutter/bin:$PATH
I tried out all the methods in previous answers, but all of them lasted only while the terminal was open. So I went ahead and directly added it to the path file permanently.
sudo nano /etc/paths
Add this to the file:
/Users/yourUserName/Development/flutter/bin
Save the file by pressing Ctrl + X, Y and then Enter. Close the terminal and reopen it again. Tada!
If you are using zsh, you need to follow the steps below on Mac.
$HOME
location of your Mac..zshrc
file.nano ~/.zshrc
into an iTerm2 terminal.PATH=$HOME/flutter/bin:$PATH
~/.zshrc
file.Do the following steps:
Download the Flutter SDK
Flutter SDK Archive
Extract it where do you want (for example /home/development/flutter
)
Set your PATH. Edit your file with the command gedit ~/.profile
. You need to add this line:
export PATH=[location_where_you_extracted_flutter]/flutter/bin:$PATH
I showed you above where I've extracted mine, so my export will look like this:
export PATH=/home/myUser/development/flutter/bin:$PATH
Save the file and close it.
Run source ~/.profile
to load the changes
If you now run flutter doctor
, it should work!
If you are on macOS
First find the location of your Flutter SDK
Flutter SDK File: Write the below command on your terminal to download the Flutter SDK
git clone https://github.com/flutter/flutter.git
For example: the SDK executable file name is flutter
and it is in folder Downloads
Close and open your terminal again.
And enter the following commands in your terminal
cd Downloads # Go to Downloads
cd flutter # Go to folder 'flutter'
pwd # /Users/[USERNAME]/downloads/flutter/
whoami # Your [USERNAME]
export PATH="/Users/[USERNAME]/downloads/flutter/bin":$PATH
In your terminal, run:
touch $HOME/.bash_profile
vi $HOME/.bash_profile
Now use I
to insert and paste the following:
export PATH="$PATH:$HOME:/PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin"
Use Esc and type :wq!
to save the file and exit.
Refresh:
source $HOME/.bash_profile
And verify it's OK by running:
echo $PATH
You must have the .bash_profile file and define the flutter path in the .bash_profile file.
First of all, if you do not have or do not know file .bash_profile, please look my answer: How do I edit $PATH (.bash_profile) on OSX?
You should add the below line (.../flutter_SDK_path/flutter/bin) in your .bash_profile:
export PATH=$PATH:/home/username/Documents/flutter_SDK_path/flutter/bin
After these steps, you can write Flutter code such as, flutter doctor
, flutter build ios
, flutter clean
, etc. in the terminal of a MacBook.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With