Flutter command not found
Solution 1
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 typingnano ~/.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:
- Open Terminal
- Run:
nano ~/.zshrc
- Add:
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
- Run:
source ~/.zshrc
- restart terminal
- Run:
flutter doctor -v
For example : if flutter in your machine has been installed under [your_username]/Developer/flutter
export PATH=Developer/flutter/bin:$PATH
Solution 2
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!
Solution 3
If you are using zsh, you need to follow the steps below on Mac.
- Download the latest Flutter version from the official site.
- Unzip it and move to the
$HOME
location of your Mac. - Add to the path via the
.zshrc
file. - Run
nano ~/.zshrc
into an iTerm2 terminal. - Export
PATH=$HOME/flutter/bin:$PATH
- Save and close the
~/.zshrc
file. - Restart iTerm2.
- Now you will have the Flutter executable available.
Solution 4
Do the following steps:
-
Download the Flutter SDK
-
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!
Solution 5
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
Related videos on Youtube
Comments
-
heyr over 2 years
Apparently, none of the Flutter commands are working in the terminal of Android Studio which I believe I am trying to run it at the root of my project.
Output:
bash: flutter: command not found
-
lee over 5 yearsHi @Tree: After did above steps. And then run
echo $PATH
get the result:/Users/username/Documents/Project/Test/flutter/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Applications/Wireshark.app/Contents/MacOS:Users/username/Documents/Flutter/flutter/bin
. But I still got the same error when runflutter create -t module myapp_flutter
-
lee over 5 yearsError:
-bash: flutter: command not found
. Please help me fix it. -
Corona about 5 yearsThis absolutely works! (if it does not, restart your terminal)
-
mle about 5 yearsPlease use the markdown feature of the text editor to structure your answer a little more, so that it's easier for others to read and understand.
-
FutureJJ almost 5 yearsDoesn't work when the terminal is reopened, please help.
-
FutureJJ almost 5 yearsThis worked, none of the other methods worked, the magic was to export the path to bashrc instead of any other paths. Thanks!!
-
m3g4tr0n almost 5 years@FutureJJ Restart Your Computer
-
FutureJJ almost 5 years@m3g4tr0n nope doesn't fix the issue. Exporting the above-mentioned path in .bashrc instead of .bash_profile fixed my issue.
-
m3g4tr0n almost 5 yearsGreat ..I am using Linux Mint 19.1 and adding code provided above in /etc/profile + restarting solved my issue..Without restarting the solution provided above doesn't work when terminal is reopened
-
Daniel almost 5 years@Tree, step 5, very important. I have seen videos that omit it. Thank you.
-
ymerdrengene almost 5 yearsThis worked for me too! And it still works after restart of terminal
-
Harshit Jindal almost 5 years@FutureJJ Updating in .bashrc instead of .bash_profile worked for me too
-
Aniruddha Shevle almost 5 years@m3g4tr0n: Even after restarting my PC didn't work! I'm using MAC OS.
-
m3g4tr0n almost 5 years@AniruddhaShevle Check out Caner's answer below it's for MAC OS
-
Ives.me over 4 yearsThis worked. Just to expand the response. After adding the path to the file, press CTRL + X, Y and then ENTER. Now completely close(Quit) the terminal and reopen it again. Try the command flutter and it should work
-
SametSahin over 4 yearsWhy is modifying .bash_profile works instead of .bashrc or vice-versa on a Mac? The installation guide on flutter.io says it's .bashrc we need to add the line but it was not the case for me.
-
B.shruti about 4 yearsAdding path in my .profile worked for me , add this in terminal gedit ~/.profile, and then add export PATH=/home/myUser/development/flutter/bin:$PATH
-
luke cross about 4 yearsStill are perfect answer to Manjaro problems and Arch base.
-
Derence about 4 yearsThis is the only answer that worked for me. Thank you! To clarify for other beginners, you need to add "Users/yourUserName/yourPathToWhereYouInstalledFlutter/flutter/bin" (In my case, "/Development/" was "/Developer/SDKs/")
-
pavel about 4 yearsI can't understand how to config this
-
Genes about 4 yearsI'm using Ubuntu 20.04 The solution worked while using ZSH terminal the .bashrc and .bash_profile do not work only the .zshrc solves the problem
-
Tarun Seera almost 4 yearsthanks bro this worked for me, however for catelina I have used .zshrc instead .profile
-
dayer4b almost 4 yearsyou can use backticks (`) to set off monospaced code text. Example:
export PATH=$PATH
(this is typed as `export PATH=$PATH`) commonmark.org/help -
Prags almost 4 years@RonyB. i could not find "text file window. " in my code please describe
-
Matrosov Oleksandr over 3 yearsStep 3 is confused where to add this (Add the following line and change)?
-
Lakshman Pilaka over 3 yearspdating in .bashrc instead of .bash_profile worked for me
-
Crystal over 3 yearsI cannot find the "Flutter SDK" I do however see "fluttter_patched_sdk" twice and "flutter_patched_sdk_product" twice. Where would it normally be stored?
-
Pritam Mullick over 3 yearsThanks! This worked for me in macOS Catalina, however following below according to the Flutter docs wasn't working for me:
export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin"
-
BNetz over 3 yearsGreat instruction, worked on macOS 10.15 (Catalina). Good to follow because of the detailed and concrete examples!!
-
Saman over 3 yearsNice! Worked for me!
-
Ali Akram about 3 years
echo $SHELL
will tell which shell you are using. -
Peter Mortensen about 3 yearsYou ought to add note about
mangesh
being your user name (thus different for everybody else) - or similar. But without "Edit:", "Update:", or similar - the answer should appear as if it was written today. -
Peter Mortensen about 3 yearsWhat is the "Wireshark Path problem"?
-
Peter Mortensen about 3 yearsPerhaps the guide doesn't mean "pwd" literally, but "current working directory"? Or the environment variable
PWD
(capital letters - the notation would probably need to be$PWD
or${PWD}
)? In any case, how reliable is the current working directory (not a rhetorical question)? -
Peter Mortensen about 3 years"resource" for "rc"? Doesn't it stand for "run commands"? (Though, I was once told it stood for "recovery".)
-
Peter Mortensen about 3 yearsWasn't it an macOS upgrade that changed the default shell?
-
Dipin Krishnan almost 3 yearsThanks. If you are BigSur user, try only this.
-
Christopher Chalfant almost 3 yearsIf you're struggling using ~/.zshrc be sure to remove the quotes!
-
Vindhya Pratap Singh almost 3 yearsWrite export PATH="$PATH:/home/mangesh/Documents/flutter_data/flutter/bin/" in bash profile it works for me also mentioned on flutter doc. May be different for different shell.
-
Delmontee almost 3 yearsFor people like me who dont use macs - this above method works. Just open Visual studio, type the "sudo nano /etc/paths" line, which opens up a file in the terminal, then you literally add the next line to the bottom of the list and save it. close and reopen terminal and it works. My flutter sdk was installed on desktop so replaced "/Development" with "/Desktop"
-
fsalazar_sch over 2 yearsDid the same it doesn't work, please check your solution
-
user2822565 over 2 yearsThis is the way the tutorial should have people do it, thanks! Don't forget to open a new terminal and test it flutter works globally by checking the version outside of the flutter folder using "flutter --version"
-
Aiiboo over 2 yearsthanks that's work for me too on macOS Monterey (12.1)
-
Bitlejuce Do about 2 yearsBest answer, should be on top. Thanks
-
user1034912 about 2 yearsplease add more detail. where is .bashrc file?
-
Mousa Alribi about 2 yearsfor me I added in .bash_profile { export PATH="$PATH:
pwd
/flutter/bin" export PATH="$PATH:pwd
/flutter/" export PATH="/Users/CHANGETHISTOYOURS/flutter/bin:$PATH" } and it worked in terminal and android studio with no issues ! -
Madian Malfi about 2 yearssource ~/.zshrc ,what i was missing
-
Leon Matota about 2 yearsOut of all options, this worked for me. Thank you
-
ioopl almost 2 yearsMy issues was this error
bash: melos: command not found
and ultimately this worked for meflutter pub global activate melos 0.4.11+2