Flutter command not found
Asked Answered
C

26

188

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
Citral answered 1/6, 2018 at 23:22 Comment(0)
A
608

You need to correctly set up your Flutter path.

From macOS install - Update your path:

  1. Determine the directory where you placed the Flutter SDK. You will need this in Step 3.

  2. 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.

  3. 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
    
  4. Press Ctrl + X and when it asks you to save the file, choose Yes

  5. Run source $HOME/.bash_profile to refresh the current window or restart the terminal

  6. 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:

  1. Open Terminal
  2. Run: nano ~/.zshrc
  3. Add: export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
  4. Run: source ~/.zshrc
  5. restart terminal
  6. 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
Aldaaldan answered 1/6, 2018 at 23:22 Comment(24)
Hi @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 run flutter create -t module myapp_flutterCuirbouilli
Error: -bash: flutter: command not found. Please help me fix it.Cuirbouilli
Doesn't work when the terminal is reopened, please help.Infeasible
@Infeasible Restart Your ComputerWharfage
@Wharfage nope doesn't fix the issue. Exporting the above-mentioned path in .bashrc instead of .bash_profile fixed my issue.Infeasible
Great ..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 reopenedWharfage
@Tree, step 5, very important. I have seen videos that omit it. Thank you.Cheekpiece
@Infeasible Updating in .bashrc instead of .bash_profile worked for me tooSachsen
@m3g4tr0n: Even after restarting my PC didn't work! I'm using MAC OS.Sheeree
@AniruddhaShevle Check out Caner's answer below it's for MAC OSWharfage
Why 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.Flatways
Adding path in my .profile worked for me , add this in terminal gedit ~/.profile, and then add export PATH=/home/myUser/development/flutter/bin:$PATHChantry
Step 3 is confused where to add this (Add the following line and change)?Steenbok
pdating in .bashrc instead of .bash_profile worked for meSheave
I 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?Sevigny
Great instruction, worked on macOS 10.15 (Catalina). Good to follow because of the detailed and concrete examples!!Cristicristian
echo $SHELL will tell which shell you are using.Polyunsaturated
If you're struggling using ~/.zshrc be sure to remove the quotes!Gargan
Write 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.Linderman
for 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 !Komara
source ~/.zshrc ,what i was missingConnivent
How do I "Determine the directory where [I] placed the Flutter SDK"? Android Studio downloaded the plugin from the plugin market place, and it doesn't want to tell me where it put it!... 🙄Mylohyoid
I downloaded flutter sdk zip and extracted in my user folder. I tried many ways on MacOS ventura for setting Flutter path through zshrc, zprofile, none worked, for reasons i am not sure. Then I git cloned flutter sdk and added path in .zshrc and magically it worked.Bryon
Add it at the end of .zshrc file worked for me and also appending $PATH to end of the export command itslef my path is now 'export PATH=$PATH:$HOME/Downloads/flutter_sdk_/flutter/bin:$PATH' below is syntax for adding path by command 'export PATH=$PATH:'FLUTTER_DIRECTORY_PATH':$PATH' 'FLUTTER_DIRECTORY_PATH' is the replaceable string/text including single quotes Please note that you must ENTER_PATH in between the command as below without the square brackets or double quotes. 'export PATH=$PATH:[ENTER_PATH_HERE_]:$PATH'Sounder
E
459

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 (Your Flutter Bin Path):

/Users/yourUserName/Development/flutter/bin

Save the file by pressing Ctrl + X, Y and then Enter. Close the terminal and reopen it again. Tada!

Epinasty answered 1/6, 2018 at 23:22 Comment(6)
This 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 workScotfree
This 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/")Mosul
I can't understand how to config thisPlaten
For 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"Untouchability
This 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"Quesenberry
only this answer is helpful for meStoical
M
91

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.
Myca answered 1/6, 2018 at 23:22 Comment(2)
I'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 problemSnazzy
Thanks. If you are BigSur user, try only this.Erik
H
70

Do the following steps:

  1. Download the Flutter SDK

    Flutter SDK Archive

  2. Extract it where do you want (for example /home/development/flutter)

  3. 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
    
  4. Save the file and close it.

  5. Run source ~/.profile to load the changes

  6. If you now run flutter doctor, it should work!

Hassan answered 1/6, 2018 at 23:22 Comment(4)
Still are perfect answer to Manjaro problems and Arch base.Kesler
thanks bro this worked for me, however for catelina I have used .zshrc instead .profileContinuity
Thanks! 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" Kelley
I tried and all in vain but then I added double quotes export PATH="/home/hamza/snap/flutter/common/flutter/bin:$PATH" and it worked for me .Overlooker
K
37

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
Kidderminster answered 1/6, 2018 at 23:22 Comment(0)
M
31

For zsh users:

  1. Open terminal run

    touch $HOME/.zshrc

  2. Run

    sudo nano ~/.zshrc

  3. Type

    export PATH=$PATH:/Path to your extracted flutter/Flutter/bin

  4. Press ctrl+x then press y

  5. Press Enter

  6. Close the terminal and open a new terminal and run

    flutter doctor

Mephitis answered 1/6, 2018 at 23:22 Comment(4)
Nice! Worked for me!Spermophile
thanks that's work for me too on macOS Monterey (12.1)Discretionary
For me, export PATH="$HOME/{path}/flutter/bin:$PATH" workedOrganometallic
superb straight forward, work for meIneffaceable
N
24

macOS v10.14 (Mojave); Wireshark Path problem

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
Neilla answered 1/6, 2018 at 23:22 Comment(2)
What is the "Wireshark Path problem"?Wickham
Did the same it doesn't work, please check your solutionGombroon
B
16

Do this to add the Flutter executable permanently to your path (in Ubuntu):

  1. cd $HOME

  2. gedit .bashrc

  3. Append the line:

    export PATH="$PATH:[location_where_you_extracted_flutter]/flutter/bin"
    

    in the text file and save it.

  4. source $HOME/.bashrc

  5. Open new terminal and run the flutter doctor command

Bandwidth answered 1/6, 2018 at 23:22 Comment(1)
Please 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.Jenifer
T
15

You must have the .bash_profile file and define the flutter path in the .bash_profile file.

  1. 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?

  2. 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.

Teletypewriter answered 1/6, 2018 at 23:22 Comment(2)
This absolutely works! (if it does not, restart your terminal)Cheung
This worked for me too! And it still works after restart of terminalArcuate
T
13

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
Trash answered 1/6, 2018 at 23:22 Comment(0)
H
12

On macOS v10.15 (Catalina), the issue is with the Path environment variable.

  1. Open Terminal and check the shell (command: echo $SHELL),

If output is /bin/bash, we need to convert to Z shell (Zsh). Z shell 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 Z shell.

  1. Update your Path

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

  1. Done! try (command: flutter doctor)
Hurling answered 1/6, 2018 at 23:22 Comment(0)
O
8

Add Path in this way in .bashrc 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

source ~/.profile

Then run this command:

On Linux

source ~/.profile

On Mac

source ~/.bash_profile

Or:

open -a TextEdit ~/.bash_profile

enter image description here

Then you can user any of flutter command like to build fluter apk

flutter build apk

Overshoe answered 1/6, 2018 at 23:22 Comment(3)
This worked, none of the other methods worked, the magic was to export the path to bashrc instead of any other paths. Thanks!!Infeasible
@RonyB. i could not find "text file window. " in my code please describeOvershoe
please add more detail. where is .bashrc file?Grisaille
S
6

The Flutter installation issue in macOS (specific for macOS v11 (Big Sur)).

  1. Check which shell is your default shell that you have in the terminal.
  2. To check the default shell, type command echo $SHELL.
  3. For my specific issue I have Z shell (zsh) as my default shell.
  4. So I change my Z shell as my default shell to Bash.
  5. To change the default shell, enter the below command. chsh -s /bin/bash
  6. Enter your password when you are prompted
  7. Now I have the Bash shell as my default.
  8. Then I just follow the standard process for the Flutter setup on Flutter’s official site.
  9. And I have successfully configured Flutter in my macOS.

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 repository

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 you're good to go.

Sacaton answered 1/6, 2018 at 23:22 Comment(1)
My issues was this error bash: melos: command not found and ultimately this worked for me flutter pub global activate melos 0.4.11+2Emilioemily
E
6

The Flutter SDK can be run on Windows as well as macOS.

For Windows

  1. First download the latest SDK from the Flutter download page.

  2. Now to run flutter in the Windows console, you need to update your PATH environment variable.

  3. From the Start search bar, type ‘env’ and select Edit environment variables for your account.

  4. 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 the 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

  1. First download the latest SDK from the Flutter download page

  2. 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
  3. Add the Flutter tool to your path:

    1. export PATH="$PATH:pwd/flutter/bin"

Run flutter doctor

Entwine answered 1/6, 2018 at 23:22 Comment(0)
B
5

I followed the checked answer, but when I restart the terminal, the Flutter command is not recognized again. My in file bash_profile path is:

export PATH=~/Users/aldo/Projects/Framework/flutter/bin:$PATH with ~

Then I edit it to:

export PATH=/Users/aldo/Projects/Framework/flutter/bin:$PATH without ~

And re run source $HOME/.bash_profile: Now my Flutter command is recognized even if I restart the terminal.

Barogram answered 1/6, 2018 at 23:22 Comment(0)
B
5

For Ubuntu 14.*:

There isn't any .bash_profile file, but it just the .profile file in folder /home/mangesh.

In my case, I am running this command to add the flutter/bin path,

export PATH="$PATH:/home/mangesh/Documents/flutter_data/flutter/bin/"

To verify the above change, just run,

echo $PATH

Following is my complete output,

$ pwd

/home/mangesh

$ export PATH="$PATH:/home/mangesh/Documents/flutter_data/flutter/bin/"

$ 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/
Bor answered 1/6, 2018 at 23:22 Comment(1)
You 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.Wickham
R
4

Just revert to chsh -s /bin/bash from chsh -s /bin/zsh,

Run one command

chsh -s /bin/bash

You're facing this problem just because you have changed the shell from Bash to Z shell in macOS. If you run this command again it will change the path again. So just run one command and the problem is solved.

Raft answered 1/6, 2018 at 23:22 Comment(1)
Wasn't it an macOS upgrade that changed the default shell?Wickham
A
4

On a 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 the Flutter SDK is downloaded and extracted]/flutter/bin"

For example:

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 (for example: cd ~/Development/tools/)

Step 2: Enter this command

export PATH='pwd'/flutter/bin:$PATH

That's it. Type "flutter doctor" to check if this issue gets resolved.

Arms answered 1/6, 2018 at 23:22 Comment(0)
C
4

In my case, I put the line export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH in both file .bash_profile and .bashrc (I put it on the last line).

After that, run source .bash_profile and source .bashrc. Now it's working (even if you use it in a new terminal window)!

Congeal answered 1/6, 2018 at 23:22 Comment(0)
M
4

You can easily create a symbolic link as below,

sudo ln -s /opt/flutter/bin/flutter /usr/bin/flutter

I had moved the executable flutter into the /opt/ folder after downloading, so replace it with the path you have for the directory the flutter executable is in.

The flutter command should work even after rebooting your machine.

Maiamaiah answered 1/6, 2018 at 23:22 Comment(0)
P
3

On a Mac I followed the steps of the user Tree, but I still received the answer "flutter: command not found".

I then went to the folder flutter/bin and inside this folder Ctrl + click on the 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.

Puffer answered 1/6, 2018 at 23:22 Comment(0)
H
2

If you are facing this issue from a Windows 10 machine, this is how I solved it:

First of all, find your Flutter executable path, and then your bin folder under the Flutter path

E.g., "C:\flutter\bin"

Copy it, and press the windows button. Type: environment, and press "Edit the system environment variable"

Press the "Environment variable" button

Double click on the "Path" menu

Add a new path, using the bin address

E.g., ""C:\flutter\bin"

This should work.

Halftone answered 1/6, 2018 at 23:22 Comment(0)
C
2

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

Crater answered 1/6, 2018 at 23:22 Comment(0)
G
2

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

Gogh answered 1/6, 2018 at 23:22 Comment(2)
you can use backticks (`) to set off monospaced code text. Example: export PATH=$PATH (this is typed as `export PATH=$PATH`) commonmark.org/helpAitch
"resource" for "rc"? Doesn't it stand for "run commands"? (Though, I was once told it stood for "recovery".)Wickham
K
2

The Flutter installation guide says you add this:

export PATH="$PATH:pwd/flutter/bin"

Visual Studio Code doesn't support pwd for some reason. The fix:

export PATH="$PATH:~/flutter/bin"
Kiesha answered 1/6, 2018 at 23:22 Comment(1)
Perhaps 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)?Wickham
P
2

Ubuntu 16.04 (Xenial Xerus):

I added the path correctly for Flutter, Java, Android Studio, and Android SDK in the .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

And then:

source /home/your_name/.bashrc

Then run flutter doctor. It works fine.

So every time, if I want to run flutter doctor, I have to run these two commands above.

Particularize answered 1/6, 2018 at 23:22 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.