After upgrade MacOS terminal showing: zsh: command not found: flutter
Asked Answered
S

15

128

Recently I updated Mac OS to latest Catalina. Now when entering a flutter command like the following,

flutter --version

my terminal (which is using zsh) shows me following error:

zsh: command not found: flutter

How do I reinstate the path to allow flutter commands from any directory?

Starvation answered 15/10, 2019 at 18:16 Comment(5)
first answer ok, but for who does not like vim here is other way for Ubuntu users: 1. open terminal ``` ctrl + alt + t ``` 2. `` nano $HOME/.zshrc ``` 3. at the end of the file add the following line ( please replace [flutter_dir] with your director ``` export PATH=$PATH:[flutter_dir]/flutter/bin ``` 4. exit -> save ``` ctrl + x ``` 5. source ~/.zshrcJosefjosefa
This question is clearly relevant to software tools primarily used by programmers. The fact that as of today it has 90 upvotes and that the most-upvoted answer has 305 upvotes shows how many people have found this question useful.Submaxillary
In my case, my problem was the relative path to the flutter folder. I changed it to the absolute path and it was all fine.Udine
This question shouldn't have been closed.Nether
This question shouldn't have been closedBrueghel
S
4

I followed URL to resolve my issue.

I simply created a .zshrc file which was not exist then added my PATH variables copied from existing .bashrc.

Starvation answered 16/10, 2019 at 5:45 Comment(1)
please provide the url's content, as URL's may expireSurmise
I
416

You need to update the environment path.

  1. Open terminal.

  2. vim $HOME/.zshrc

  3. Press "I" key for going to insert mode.

  4. add the following line in the opened file:

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

  5. Press "Esc" then write :wq! in terminal and press enter to exit vim.

  6. Reopen the terminal and check "flutter doctor"

If this solution did not work, remove the double quote from path or use the full path explicitly instead of ~.

Incrust answered 29/11, 2019 at 5:36 Comment(17)
Thanks. I actually used the format of PATH in my system "export PATH=/FLUTTER_DIR/flutter/bin:$PATH" and it works. the $PATH proceeds after the flutter dirBaten
is the "I" key the pipe? Or capital "I" as in Indigo or lower case "l" as in lima?Licentious
I need to remove double quote from path to get it work..Symphonious
This worked wonders! Thanks! I already had an anaconda block added automatically by the installation, I wrote export PATH=$PATH:~/development/flutter/bin above it and now both work fine.Tingly
Removing double quotes was what was needed for me. Thanks!Evelynneven
This export PATH="$HOME/.flutter/bin:$PATH" worked for me. On macOS Big Sur 11.2.3(Apple M1).Shwalb
I can't understand, you solution works for me but flutter extends only in $HOME directory. If I call flutter in sub directory, for example $HOME/Downloads, it still says flutter not found. What should I do?Chordate
didn't work for me with or without double quotesLockyer
Also Exit terminal and again open it. to run flutter doctor in working state.Mame
don't forget to type source .zshrc after editing .zshrcDowndraft
@GiordanPretelin thanks you saved my time. export PATH=$PATH:~/flutter/binPound
If this solution did not work, write it: export PATH="$PATH":"$HOME/development/flutter/bin"Hassle
export PATH=$PATH:/YOUR_FLUTTER_DIR/flutter/bin works for me. Without the double quote. Also, I had the same line twice and I faced the same error. Make sure that you have only one line.Petrel
I is capital i, @LicentiousDenisdenise
Removing double quotes was what was needed for me. ThanksWayward
I was searching how to do this, thank you man. If I had 2 accounts I would push 2 upvotes for you.Lombard
for me adding this export line to .zshenv file(not .zshrc) helpedAngeliqueangelis
K
98

Working on macOS Catalina 10.15.5 (19F101). I have used .zprofile instead of .zhrc

  1. Provide Full Disk Access to Terminal by Setting -> Security & Privacy -> Full Disk Access. Add Terminal

  2. If the current terminal uses bash, change to zshell using the below command

    chsh -s /bin/zsh

  3. In the root directory i.e something like /Users/^YourAccount^ execute the below

    touch .zprofile

    vim .zprofile

  4. Press I to enter insert mode. Type the below

    export PATH=$PATH:/Users/^YourAccount^/^YourPath^/flutter/bin

  5. Save and quit by pressing Esc, then :wq and Enter

  6. Close Terminal and reopen Again. Then try executing flutter command

Kolnick answered 26/6, 2020 at 19:9 Comment(10)
First recommendation "Provide Full Disk Access to Terminal by Setting -> Security & Privacy -> Full Disk Access. Add Terminal" works for me. Tnx.Flint
Worked for me as well ! Thanks for helpLuteal
Why we are giving full disk access to terminal ? @KolnickLuteal
As because we are using terminal to execute the flutter commands. I am not very sure of the specifics.Kolnick
Providing full disk access worked for me. I did all the stuff given in the above answer.Suspensoid
Thanks.After long research I got the solutionStereotyped
Workin on macOs Catalina 10.15.7 (19H1519)Trisomic
This worked for me! After following these steps, I deleted the flutter SDK 'cache' folder inside the bin folder, then went into my flutter project and ran flutter clean then flutter run. I'm using a macOS Big Sur, version 11.6.4, Thanks so much!Intrigant
Also worked on Monterey. Thanks!Massproduce
I'm using macOS Monterey Version 12.5.1, and it worked for me :)Celloidin
W
66

For me removing double quotes did the fix.

Try changing

export PATH="$PATH:[PATH TO FLUTTER]/flutter/bin"

into

export PATH=$PATH:[PATH TO FLUTTER]/flutter/bin

adding few more steps for easiness:

Open terminal.

vim $HOME/.zshrc

Press "I" to open insert mode.

add the following line in the opened file:

export PATH=$PATH:[PATH TO FLUTTER]/flutter/bin (remember I don't have double quotes here)

Press "Esc" then type :wq in terminal to exit edit mode.

Type source .zshrc to reload the terminal for changes

Welles answered 2/8, 2020 at 6:35 Comment(3)
source .zshrc to reload the terminal worked for me. Thanks!Cheatham
It's weird, but it works for me. Any explanation why removing quotes helps?Billetdoux
for Ubuntu user's please use source ~/.zshrc instead of source .zshrcJosefjosefa
B
44

You must update your environment $PATH variable.

1) Open the file $HOME/.zshrc $HOME is your home path

2) add the following line in the opened file:

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

3) save the changes and restart your terminal session.

The process is also documented here

Balloon answered 15/10, 2019 at 19:8 Comment(2)
For others wondering...(stupid me, but) the 'restart terminal session' did the trick for me. (do the same in Android Studio of Visual Studio Code!)Countervail
Same here. The post important part "restart your terminal session." Or you could spend extra 1 hour.Glenda
S
31

Follow these steps:

Open finder Enter Cmd + Shift + G

Type ~ in Go to the folder popup.

Now enter Cmd + Shift + . to show hidden files.

Open .zshrc

Add this line

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

Replace this /YOUR_FLUTTER_DIR with the path to your flutter directory. In my mac, the path is

export PATH=$PATH:$HOME/FlutterDevelopment/flutter/bin
Sam answered 1/8, 2020 at 11:51 Comment(2)
Any explanation why removing quotes helps?Billetdoux
@anber: Bcz it contains a variable $PATH, which would resolve to actual path localtion. if you still want to use "" then replace $PATH with actual path. Hope it helps.Sam
R
14

in android studio terminal, simply just type this command:

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

change YOUR_FLUTTER_DIR to your actual directory

Rizas answered 16/9, 2020 at 12:5 Comment(2)
I hate to admit it, but it wasn't working for me and your answer made me realize I left off the leading "/" in my path... doh!Glenglencoe
double quotes not needed in big SurChaiken
R
13

I updated from Mojave to Catalina and running Terminal, switched to the default/preferred zsh shell, from the bash shell. Then was hit with

zsh: command not found: flutter

so, followed the advice seen elsewhere to only add the following to Users/MyUserId/.zshrc

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

echo $PATH showed that /Users/MyUserId/flutter/bin was now one of the configured PATHs. However, I couldn't get "flutter doctor" to work but came across a post on jelliesgame.com which suggested copying

Users/MyUserId/.bash_profile to Users/MyUserId/.zshenv

Now, flutter doctor gives a clean bill of health

Reflexion answered 27/10, 2019 at 17:11 Comment(1)
this is because some other exports have messed your zsh profile. Who experience similar issues - check if you have messed lines like 'export PATH=/opt/homebrew/bin$PATH' and change them to export PATH=/opt/homebrew/bin/:$PATH - notice : symbol before PATHCoricoriaceous
T
11

This worked for me:

Steps:

  1. Type on the terminal:
    open .zshrc (This opens the document in text edit)
    
  2. Add this to the end of the file:
    export PATH="/Users/YOUR_USERNAME/Documents/code/tools/flutter/bin:$PATH"
    
  3. Save and close .zshrc
  4. Then type:
    flutter doctor
    
Thomasthomasa answered 1/11, 2020 at 10:59 Comment(0)
C
9

Had the same issue and just realized that I forgot to add the close quote

So the correct way is to add to .zshrc by typing vim ~/.zshrc

PATH="$PATH:$HOME/Flutter/flutter/bin"

or

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

then run source ~/.zshrc or just open a new terminal window

Cornett answered 5/3, 2020 at 17:1 Comment(0)
H
6

I tried installing flutter on my MAC according to the advice here, but it still doesn't work, after searching for it I found an article here.

So, I change my .zshrc file to:

export PATH="$PATH:/Users/YOUR_PROVILE_NAME/YOUR_DEVELOPMENT_FOLDER/flutter/bin"

Change YOUR_PROVILE_NAME to your name profile, also YOUR_DEVELOPMENT_FOLDER to your development folder for flutter

and now it's working.

Note: I use Catalina OS v10.15.4

Higginbotham answered 31/5, 2020 at 1:0 Comment(1)
This did the trick for me as well, thanks! I'm on macOS Big Sur 11.0Blagoveshchensk
S
4

I followed URL to resolve my issue.

I simply created a .zshrc file which was not exist then added my PATH variables copied from existing .bashrc.

Starvation answered 16/10, 2019 at 5:45 Comment(1)
please provide the url's content, as URL's may expireSurmise
S
3

I had the same problem when upgrading to mac Catalina 10.15.4:

After many days of research, I have achieved success. Here are the steps I did:

First, open the terminal on your mac.

Next, use the command

 cat .bash_profile

and copy the content.

Then type this command into the terminal:

nano $ HOME / .zshrc

and paste the content just copied above into. Save then type

source $ HOME / .zshrc

to refresh this file. Next type

echo $ PATH

to see if the content has been updated. If successful type

flutter --version

and you will see the result.

Sapotaceous answered 18/5, 2020 at 11:33 Comment(0)
O
3

There are quite a few answers mentioned above pretty much same. I would say worth seeing into the SHELL using echo $SHELL command,

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.

N.B. Don't forget you need to add VIM before either command in the terminal app.

For further details, click the link Update your path, and look into the section Update your Path. I hope it would help many especially new comers to MAC OS. Cheers

Obliquely answered 4/8, 2020 at 10:52 Comment(0)
A
3

For me .zshrc worked instead of .zprofile. I believe this is because I had created .zshrc earlier and now when I tried creating .zprofile, it was looking into .zshrc file.

You can check if .zshrc file using ls -a command

Astronomer answered 10/8, 2020 at 16:5 Comment(0)
A
0

For me moving the flutter folder to document page and setting the new path solved the issue

before-> /Users/kunalkalwar/Desktop/AndroidProjects/Softwares/flutter

after-> /Users/kunalkalwar/Documents/flutter

Arrival answered 13/10, 2023 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.