bash: flutter: command not found
Apparently, none of the flutter commands are working on the terminal of an android studio which I believe I am tryi
You need to correctly set up your flutter path.
from here https://flutter.dev/docs/get-started/install/macos#update-your-path
$HOME/.bash_profile
. You can do that by using terminal text editor by going in terminal and typing nano ~/.bash_profile
macOS Catalina uses the Z shell by default, so edit $HOME/.zshrc.
If you are using a different shell, the file path and filename will be different on your machine.
[PATH_TO_FLUTTER_GIT_DIRECTORY]
to be the path where you cloned Flutter’s git repo:export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
for example:
export PATH=~/Documents/flutter/bin:$PATH
press CTRL X
and when it asked 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 ~/.bash_profile
To those who still don't have the solution, it's because your path is wrong. Putting it in .bashrc or .profile works as long as your path is correct. Please check your flutter directory and see where the folder bin is located. mine looks like this
export PATH=$HOME/flutter/flutter/bin:$PATH
In macOS Catalina the default shell is Zsh. I did Following command on Terminal:
In Mac, There are two options to solve this issue.
Option 1: Adding the flutter SDK path permanently(it will work in any terminal session)
Download the flutter SDK and extract in any location and then you have to add the below line in $HOME/.bash_profile file(hidden folder as default).
export PATH="$PATH:[where flutter sdk downloaded and extracted]/flutter/bin"
for eg:export PATH="$PATH:~/development/tools/flutter/bin"
Option 2: If you are facing any difficulties with Option 1, then this is much simpler but you have to do this simple step whenever you restart your system/terminal.
Step 1: Go to the path where flutter SDK downloaded and extracted (eg: cd ~/Development/tools/)
Step 2: Enter this command
export PATH='pwd'/flutter/bin:$PATH
That's it. Type "flutter doctor" to check this issue gets resolved. Happy Coding.
Ubuntu 16.04 :-
I added the path correctly for Flutter, Java, Android Studio and Android SDK in .bashrc file , but when I run flutter doctor, the terminal returns
flutter: command not found
Solution :-
So,first I had to always run ->
sudo su
then ->
source /home/your_name/.bashrc
Then run flutter doctor, it works fine.
So everytime, If I want to run flutter doctor, I have to run these above 2 commands.
Hope it helps :)
In my case, I put that line export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
to both file .bash_profile and .bashrc (put it on the last line). After that, run source .bash_profile
and source .bashrc
. Now it's working!, even if you close the terminal.