Question:
bash: flutter: command not found
Apparently none of the flutter commands are working on the terminal of android studio which I believe I am trying to run it at the root of my project.
Answer 1:
You need to correctly set up your flutter path.
from here https://flutter.dev/docs/get-started/install/macos#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 typingnano ~/.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.
- Add the following line and change
[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
Answer 2:
Tried out all the above methods, but all of them lasted only until 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, Tada!
Answer 3:
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 this 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 run now
flutter doctor
should work!
Answer 4:
If you are using zsh, you need to follow below steps in mac.
- Download latest flutter from the official site.
- Unzip it and move to the
$HOME
location of your mac. - Add to path via
.zshrc
file- run
nano ~/.zshrc
into iTerm2 terminal. - export
PATH=$HOME/flutter/bin:$PATH
- Save and close
~/.zshrc
file. - re-start iTerm2
- run
- Now you will have flutter available.
One if the Answers above should be able to answer your question.