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 trying to run it at the root of my project.
This question is related to
android-studio
flutter
dart
command-line
terminal
The answer given by this is correct to me : https://github.com/flutter/flutter/issues/15408#issuecomment-373424994
After cloning the repo, don't cd ./flutter before running the commad. the pwd represent the current directory where you were before cloning the repo. The full command is:
export PATH=`pwd`/flutter/bin:$PATH
You can make life easier by adding it to your bashrc or zshrc
Move flutter to home dir
$ mv flutter ~
Add the path to your ~/.zshrc
path+=('/home/username/flutter/bin')
export PATH
Source it source ~/.zshrc
You must have .bash_profile file and define flutter path in .bash_profile file.
First of all, if you do not have or do not know .bash_profile, please look my answer: How do I edit $PATH (.bash_profile) on OSX?
You should add 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 codes such as, flutter doctor
, flutter build ios
, flutter clean
or etc. in terminal of Macbook.
@canerkaseler
As I can't comment, I'm answering:
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
Previously i was giving my whole path like this:
export PATH=Users/Tekion/Downloads/flutter/bin:$PATH
It started working after i changed my whole path to
export PATH=$HOME/Downloads/flutter/bin:$PATH
run the command like this on Windows
C:\flutter\bin> .\flutter doctor
On MacOS Catalina, open terminal, follow this step:
if exact location unknown then this command help
export PATH=~/flutter/bin:$PATH
For MacOs Catalina users with ZSH Shell.
The following procedure fixes the "command not found: flutter".
Open your terminal, go to your home directory and type the following command:
export PATH ="/YourHomeDirectory/YourUsername/YourDirectory/flutter/bin:$PATH"
Check the version of Flutter you have, write the following command:
flutter --version
Dart and some tools will be downloaded. After a few minutes, you will be ready to work.
If you use zsh shell instead of Bash shell, you must edit the .zshrc file (it is located in your home directory) and write the following command at the end:
export PATH="/YourHomeDirectory/YourUsername/YourDirectory/flutter/bin:$ PATH"
This will make the change permanent, if you don't edit the .zshrc file the change will be lost when closing the terminal window.
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 by pressing CTRL + X, Y and then Enter. Close the terminal and reopen it again. Tada!
After setting up and properly configuring my PATH variables i still got the error message
command not found: flutter
It's very important that you don't forget to restart your terminal for the changes to take effect.
Simply run source $HOME/.bash_profile
to refresh/restart the terminal.
If you're on a macOS using the Z shell you should add the path to your flutter bin directory to $HOME/.zshrc
For those using a Z-shell resource (.zshrc), navigate to your home directory and open .zprofile, copy and paste this: export PATH=[PATH_TO_FLUTTER_DIRECTORY]/flutter/bin:$PATH
Flutter SDK can be run on windows as well ass macOs
For Windows
Under User variables check if there is an entry called Path:
1.If the entry does exist, append the full path to flutter\bin using ; as a separator from existing values.
2.If the entry does not exist, create a new user variable named Path with the full path to flutter\bin as its value.
For Mac
First download the lates SDK from flutter download page
Extract the file in the desired location using following commands :
1. cd ~/development
2.unzip ~/Downloads/flutter_macos_v1.5.4-hotfix.2-stable.zip
Add the flutter tool to your path:
1.export PATH="$PATH:`pwd`/flutter/bin"
Run flutter doctor
Do this to add flutter permanently to your path (in Ubuntu):
cd $HOME
gedit .bashrc
export PATH="$PATH:[location_where_you_extracted_flutter]/flutter/bin"
in the text file and save it.
source $HOME/.bashrc
flutter doctor
commandDo 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
source ~/.profile
to load the changesflutter doctor
should work!I faced this problem and I resolved it following these steps:
: nano ~/.bash_profileexport
: add this line: PATH=/Users/user/Documents/flutter_sdk/flutter/bin:$PATH make sure the dir to your flutter bin is correct.
:source ~/.profile
If you are on MAC OS
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 file name is flutter and it is in Downloads
Close and open your terminal again
and enter the following commands in your terminal
cd Downloads #go to Downloads
cd flutter #go to flutter
pwd #/Users/[USERNAME]/downloads/flutter/
whoami #Your [USERNAME]
export PATH="/Users/[USERNAME]/downloads/flutter/bin":$PATH
I hope you will manage on based on the example I have given. Upvote the answer if you find it useful.
The best way to setup Flutter on Mac
1. Open a new terminal window
2. Type: git clone https://github.com/flutter/flutter.git -b stable
Wait for the SDK to clone onto your machine
3. Type: export PATH="$PATH:`pwd`/flutter/bin", which adds flutter tool to your path
4. Type: flutter doctor , which downloads additional dependencies
Wait for dependencies to download and install
after follow installation guide, download and extract, just try this command, you can change file depending on where you extract SDK, in my case it was home and works fine..
export PATH="$PATH":"$HOME/flutter/bin"
then try:
flutter --version
if works don't forget to complete remain installation steps.
If your are facing this issue from a Windows 10, that's how i solved this
first of all, find your flutter path, and than your bin folder under de flutter path
e.g. "C:\flutter\bin"
copy it, then pres the windows button, type: environment, and press "Edit the system environment variable"
press "environment variable" button
double click on "Path" menu
Add a new path, using the bin address
e.g ""C:\flutter\bin"
this should work
In macOS, please edit .zshrc
file instead of .bash_profile
file.
The content of .zshrc
file is
export PATH=[PATH_TO_FLUTTER_DIRECTORY]/flutter/bin:$PATH
flutter document tell us
cd ~/development
unzip ~/Downloads/flutter_macos_1.17.5-stable.zip
directory like this
/development/flutter_macos_1.17.5-stable/bin/
Then he told us to do this
export PATH="$PATH:`pwd`/flutter/bin"
Then the problem is coming, the file path name does not correspond
wtf?
you need change file name like this
/development/flutter/bin/
or change export path
export PATH="$PATH:`pwd`/flutter_macos_1.17.5-stable/bin"
Open your .bash_profile
file located under Finder>Go>Home. Add below lines at the end of
export PATH=$PATH:/Users/Projects/Flutter/sdk/bin
Don't forget to replace /Users/Projects/Flutter/sdk/bin
with your flutter path.
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
Just revert to chsh -s /bin/bash from chsh -s /bin/zsh
,
Run one command
chsh -s /bin/bash
Your facing this problem just because of you have change shell from /bash to /zsh in macOs. If you run this command again it will change the path again. So just run one command and problem solve.
My solution was to open the bash file in the terminal.
You need to edit you Zsh or 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 == Location to your flutter SDK file.
To edit $HOME/.zshrc:
open Terminal
copy and paste nano $HOME/.zshrc
copy next line and paste it at bottom
export PATH="[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH"
Edit your [PATH_TO_FLUTTER_GIT_DIRECTORY].
It will look something like this--> for example:
export PATH="/Users/flutter/bin:$PATH"
press CTRL X and when it asked you to save the file, choose yes.
Close and Restart the Terminal and try running flutter doctor
Verify that the flutter/bin directory is now in your PATH by running:
echo $PATH
[PATH_TO_FLUTTER_GIT_DIRECTORY] is where you installed flutter SDK.
Instead of nano, you can use any text editor to edit ~/.bash_profile or .zshrc
this works for me.
i was giving my whole path like this:
export PATH=Users/Tekion/Downloads/flutter/bin:$PATH
It started working after i changed my whole path to
export PATH=$HOME/Downloads/flutter/bin:$PATH
So far, looking all the solution, none of them worked for me.
So I did it, with the help of alias
in Linux
You set the alias as,
alias flutter='~/your/path/to/flutter/bin/./flutter'
Now, just type flutter doctor
to see if it works.
To create alias permanently, See
If you are using zsh, you need to follow the steps below in mac.
$HOME
location of your mac..zshrc
file.nano ~/.zshrc
into iTerm2 terminal.PATH=$HOME/flutter/bin:$PATH
~/.zshrc
file.For Linux: To remember flutter commands permanently:
1.) open up terminal and cd to $HOME. for eg: username@linux:~$
2.) open the hidden file .bashrc
with your desired editor. It resides in $HOME.eg. sudo gedit .bashrc
3.) add the following line export PATH=/home/username/flutter/bin:$PATH
somewhere as a newline in .bashrc file preferably as the last line edit & save the file.
4.) run source /home/yourname/.bashrc
in terminal to process your recent changes.
5.) finally, run echo $PATH to see flutter dir is in your system path along with other such paths. for eg: /home/username/flutter/bin
@Happy_Coding.
You need to set the path correctly.and also if you are facing problem like it is now working when the terminal is reopened then you should try this method and simply restart your computer after doing.
open your terminal and type
nano ~/.profile
and add this line end of the file and change Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY] to be the path where you cloned Flutter’s repository.
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
For example i am showing you what i have done in my case.
Now simply ctrl + O and hit enter
then type in your terminal
source ~/.profile
and to check your path just run
echo $PATH
now just simply type flutter
in your terminal. hope it will work.
You can easily create a symbolic link as below,
sudo ln -s /opt/flutter/bin/flutter /usr/bin/flutter
I had moved flutter into /opt/ folder after downloading, so replace with the path you have flutter directory.
flutter command should work even after rebooting your machine.
For zsh users:
Open terminal run
touch $HOME/.zshrc
Run
sudo nano ~/.zshrc
Type
export PATH=$PATH:/Path to your extracted flutter/Flutter/bin
Press ctrl+x then press y
Press Enter
Close the terminal and open a new terminal and run
flutter doctor
Add Path in this way in .bashrc
for Linux and for Mac .bash_profile
of android sdk and tools with flutter
export PATH=$PATH:/user/Android/Sdk/platform-tools:/user/Android/Sdk/build-tools/27.0.1:/user/Android/Sdk/tools:/user/Android/Sdk/tools/bin:/user/Documents/fluterdev/flutter/bin:$PATH
Then run this command
On Linux
source ~/.profile
On Mac
source ~/.bash_profile
oropen -a TextEdit ~/.bash_profile
Then you can user any of flutter command like to build fluter apk
flutter build apk
On macOS Catalina ,The issue is with Path
If output is /bin/bash
We need to convert to Zsh. Zsh is only the default shell on newly created user accounts, so any existing accounts you have on an upgraded Mac will still use Bash by default unless you change it. simply run the chsh -s (change shell) command in a Terminal window.
[command : chsh -s /bin/zsh ]
Enter your password when prompted. After you close the terminal window and reopen it, you’ll be using Zsh.
2.1. Open the zshrc file [command : vim ~/.zshrc ]
2.2. Press 'I' to insert the path as [ export PATH=~/Dev/flutter/bin:$PATH ] ,here ~/Dev/ is the Folder where Flutter is installed
2.3. Hit ESC Key and then :wq to save and exit the file
In macOS Catalina the default shell is Zsh. I did Following command on Terminal:
flutter installation issue in Mac OS (Specific for Big Sur).
Extract the file in the desired location, for example:
—> $ cd ~/development —> $ unzip ~/Downloads/flutter_macos_1.22.5-stable.zip
Add the flutter tool to your path:
export PATH="$PATH:`pwd`/flutter/bin"
This command sets your PATH variable for the current terminal window only. To permanently add Flutter to your path see below.
—> Determine the directory where you placed the Flutter SDK. —> Open (or create) the rc file for your shell. Typing echo $SHELL in your Terminal tells you which shell you’re using. 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.
—> 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:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin"
—> Run source $HOME/.<rc file>
to refresh the current window, or open a new terminal window to automatically source the file.
—> Verify that the flutter/bin directory is now in your PATH by running:
echo $PATH
—> Verify that the flutter command is available by running
—> which flutter
—> now run below command.
$ which flutter dart
/path-to-flutter-sdk/bin/flutter
/usr/local/bin/dart
—> And your good to go.
Use the following steps for setup
Download from Flutter SDK for Mac https://flutter.dev/docs/get-started/install/macos
Extract the Flutter SDK zip (saved in Downloads) file using terminal. If you want to extract the Flutter SDK in fluttrerDevelopment folder
$ cd ~/fluttrerDevelopment
$ unzip ~/Downloads/flutter_macos_1.20.1-stable.zip
Add the flutter tool to your path:
$ export PATH=“$PATH:pwd
/flutter/bin"
If you have only Xcode setup in your machine then run
$ flutter create my_first_flutter_app
$ cd my_first_flutter_app
$ flutter run
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.
For Ubuntu 14.*
there is no .bash_profile
file but it just a .profile
in /home/mangesh
In my case,I am running this command to add flutter/bin path,
export PATH="$PATH:/home/mangesh/Documents/flutter_data/flutter/bin/"
To verify above change just run,
echo $PATH
Following is my complete output,
mangesh@Mangesh:~$ pwd
/home/mangesh
mangesh@Mangesh:~$ export PATH="$PATH:/home/mangesh/Documents/flutter_data/flutter/bin/"
mangesh@Mangesh:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/mangesh/Documents/flutter_data/flutter/bin/
How to Install Flutter on MacOS To permanently add Flutter to your path, follow this command line
Open (or create) the rc file for your shell. Typing echo $SHELL
in your Terminal tells you which shell you’re using. 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.
In your terminal, run:
touch $HOME/.bash_profile
vi $HOME/.bash_profile
In Catalina your default shell is ZSH, thus you can also replace the '(dot)bash_profile' to '(dot)zshrc' [without quote and replace the dot] and the rest is the same!
Also to check for environment is running, you can just type 'flutt' + TAB, and if autocomplete kicks in you are done!
Add the following line and change [Flutter SDK] to be the path where you extracted Flutter SDK and save
If this is not working:
export PATH="$PATH: /Users/Desktop/flutter/bin"
Try this instead:
export PATH="$HOME/Users/Desktop/flutter/bin:$PATH"
Save the file and close it.
Run source $HOME/.bash_profile
to refresh the current window, or open a new terminal window to automatically source the file.
And verify that the flutter/bin
directory is now in your PATH by running:
echo $PATH
For see more : https://www.youtube.com/watch?v=ZwUGHiroGBo
First, download the Flutter here: https://flutter.dev/docs/get-started/install/macos
When you created the folder with Flutter SDK, open it in Terminal using the following command:
cd ~/development
If there is no development folder run this command first:
mkdir /development
After that, you need to run the unzip command. Make sure you specify the correct path to the downloaded Flutter archive file. Run the command below:
unzip ~/Downloads/flutter_macos_1.17.1-stable.zip
Setting the Flutter tool path
In order to set up the Flutter tool path you should run this command:
export PATH="$PATH:`pwd`/flutter/bin"
Next, you need to know which shell you are using. For this run this command:
echo $SHELL
Depending on the shell run the following command: [Note, the command you will be using depends on the shell you have.]
sudo nano ~/.zshrc
or
sudo nano /.bashrc
After that in the new window, you need to add a path to the flutter tool.
Use the following command:
export PATH=$PATH:~/development/flutter/bin
The next thing you need to do is to check the Flutter dependencies.
For this, run the command:
flutter doctor
This operation will help you to identify if there are any dependencies you need to install. After the results will be prepared click Agree and wait for the installation of the needed dependencies to complete the setup. enter image description here
if u meet this error in macOS, and install zsh, I am solved in this way
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 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.
You can do these..
After you followed the tutorial, if your mac is not even able to run "flutter doctor", you should reboot your mac. This worked for me.
I followed checked answer but when i restart the terminal, the flutter command is not recognized again. my on bash_profile path is :
export PATH=~/Users/aldo/Projects/Framework/flutter/bin:$PATH
with ~
then i edit to
export PATH=/Users/aldo/Projects/Framework/flutter/bin:$PATH
without ~
and re run source $HOME/.bash_profile
now my flutter command is recognized event i restart the terminal. hope it's help another
On the mac I followed the steps of the user Tree but still received the answer "flutter: command not found". What I did next was, go to the folder flutter/bin and inside this folder ctrl+click on flutter executable and in the popup i clicked open. After that the mac already recognized this as an exception and the flutter commands already work.
The flutter installation guide says you add this:
export PATH="$PATH:pwd/flutter/bin"
VSC doesn't support pwd for some reason. The fix:
export PATH="$PATH:~/flutter/bin"
Source: Stackoverflow.com