Flutter command not found

348,023

Solution 1

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

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:

  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!

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
Share:
348,023

Related videos on Youtube

heyr
Author by

heyr

Full-stack Developer

Updated on October 01, 2021

Comments

  • heyr
    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
    lee over 5 years
    Hi @Tree: After did above steps. And then run echo $PATH get the result: /Users/username/Documents/Project/Test/flutter/bin:/usr/loca‌​l/bin:/usr/bin:/bin:‌​/usr/sbin:/sbin:/usr‌​/local/go/bin:/Appli‌​cations/Wireshark.ap‌​p/Contents/MacOS:Use‌​rs/username/Document‌​s/Flutter/flutter/bi‌​n. But I still got the same error when run flutter create -t module myapp_flutter
  • lee
    lee over 5 years
    Error: -bash: flutter: command not found. Please help me fix it.
  • Corona
    Corona about 5 years
    This absolutely works! (if it does not, restart your terminal)
  • mle
    mle about 5 years
    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.
  • FutureJJ
    FutureJJ almost 5 years
    Doesn't work when the terminal is reopened, please help.
  • FutureJJ
    FutureJJ almost 5 years
    This worked, none of the other methods worked, the magic was to export the path to bashrc instead of any other paths. Thanks!!
  • m3g4tr0n
    m3g4tr0n almost 5 years
    @FutureJJ Restart Your Computer
  • FutureJJ
    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
    m3g4tr0n almost 5 years
    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 reopened
  • Daniel
    Daniel almost 5 years
    @Tree, step 5, very important. I have seen videos that omit it. Thank you.
  • ymerdrengene
    ymerdrengene almost 5 years
    This worked for me too! And it still works after restart of terminal
  • Harshit Jindal
    Harshit Jindal almost 5 years
    @FutureJJ Updating in .bashrc instead of .bash_profile worked for me too
  • Aniruddha Shevle
    Aniruddha Shevle almost 5 years
    @m3g4tr0n: Even after restarting my PC didn't work! I'm using MAC OS.
  • m3g4tr0n
    m3g4tr0n almost 5 years
    @AniruddhaShevle Check out Caner's answer below it's for MAC OS
  • Ives.me
    Ives.me over 4 years
    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 work
  • SametSahin
    SametSahin over 4 years
    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.
  • B.shruti
    B.shruti about 4 years
    Adding 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
    luke cross about 4 years
    Still are perfect answer to Manjaro problems and Arch base.
  • Derence
    Derence about 4 years
    This is the only answer that worked for me. Thank you! To clarify for other beginners, you need to add "Users/yourUserName/yourPathToWhereYouInstalledFlutter/flutt‌​er/bin" (In my case, "/Development/" was "/Developer/SDKs/")
  • pavel
    pavel about 4 years
    I can't understand how to config this
  • Genes
    Genes about 4 years
    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 problem
  • Tarun Seera
    Tarun Seera almost 4 years
    thanks bro this worked for me, however for catelina I have used .zshrc instead .profile
  • dayer4b
    dayer4b almost 4 years
    you can use backticks (`) to set off monospaced code text. Example: export PATH=$PATH (this is typed as `export PATH=$PATH`) commonmark.org/help
  • Prags
    Prags almost 4 years
    @RonyB. i could not find "text file window. " in my code please describe
  • Matrosov Oleksandr
    Matrosov Oleksandr over 3 years
    Step 3 is confused where to add this (Add the following line and change)?
  • Lakshman Pilaka
    Lakshman Pilaka over 3 years
    pdating in .bashrc instead of .bash_profile worked for me
  • Crystal
    Crystal over 3 years
    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?
  • Pritam Mullick
    Pritam Mullick over 3 years
    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"
  • BNetz
    BNetz over 3 years
    Great instruction, worked on macOS 10.15 (Catalina). Good to follow because of the detailed and concrete examples!!
  • Saman
    Saman over 3 years
    Nice! Worked for me!
  • Ali Akram
    Ali Akram about 3 years
    echo $SHELL will tell which shell you are using.
  • Peter Mortensen
    Peter Mortensen about 3 years
    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.
  • Peter Mortensen
    Peter Mortensen about 3 years
    What is the "Wireshark Path problem"?
  • Peter Mortensen
    Peter Mortensen about 3 years
    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)?
  • Peter Mortensen
    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
    Peter Mortensen about 3 years
    Wasn't it an macOS upgrade that changed the default shell?
  • Dipin Krishnan
    Dipin Krishnan almost 3 years
    Thanks. If you are BigSur user, try only this.
  • Christopher Chalfant
    Christopher Chalfant almost 3 years
    If you're struggling using ~/.zshrc be sure to remove the quotes!
  • Vindhya Pratap Singh
    Vindhya Pratap Singh almost 3 years
    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.
  • Delmontee
    Delmontee almost 3 years
    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"
  • fsalazar_sch
    fsalazar_sch over 2 years
    Did the same it doesn't work, please check your solution
  • user2822565
    user2822565 over 2 years
    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"
  • Aiiboo
    Aiiboo over 2 years
    thanks that's work for me too on macOS Monterey (12.1)
  • Bitlejuce Do
    Bitlejuce Do about 2 years
    Best answer, should be on top. Thanks
  • user1034912
    user1034912 about 2 years
    please add more detail. where is .bashrc file?
  • Mousa Alribi
    Mousa Alribi about 2 years
    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 !
  • Madian Malfi
    Madian Malfi about 2 years
    source ~/.zshrc ,what i was missing
  • Leon Matota
    Leon Matota about 2 years
    Out of all options, this worked for me. Thank you
  • ioopl
    ioopl almost 2 years
    My issues was this error bash: melos: command not found and ultimately this worked for me flutter pub global activate melos 0.4.11+2