zsh: command not found: flutter?
Asked Answered
T

11

10

I've tried to install flutter multiple times, and could run flutter doctor once, but after closing the terminal I couldn't. Don't know how I did it, and this keeps coming on the screen.

user@users-MacBook-Pro flutter % export PATH="$PATH: /Users/user/Desktop/flutter/bin"
user/users-MacBook-Pro flutter % flutter --version
zsh: command not found: flutter
user@users-MacBook-Pro flutter %  

So I have changed my path, changed the shell to -zsh, because I work with macOS Catalina, but nothing seems to work. What should I do?

Tammeratammi answered 29/6, 2020 at 14:0 Comment(2)
You should restart your terminal and try again – Treasure
PATH is colon-separated, not colon+space-separated. – Pistareen
H
13

Open Terminal and Type:
vim $HOME/.zshrc

After that, we need to edit that file!
Press command I

Now on a new line Type:
export PATH="$PATH:/YOUR_FILE_PATH/flutter/bin Don't forget to update YOUR_FILE_PATH!

Now press esc

Now type :wq! to exit

Now restart your terminal

Hashim answered 20/9, 2020 at 19:7 Comment(0)
L
14

As Lesiak said, you need to remove the space in your string, leaving you with export PATH="$PATH:/Users/user/Desktop/flutter/bin". However, this will only change the current shell (terminal) you have open.

To make this permanent, you need to change your zsh configuration file. This is located at $HOME/.zshrc. Run this command:

$ echo 'export PATH="$PATH:/$HOME/Desktop/flutter/bin"' >> $HOME/.zshrc

This appends export PATH="$PATH:/$HOME/Desktop/flutter/bin" to the end your .zshrc file. Note that it is crucial that you use >> and not >. >> appends to the file, > overwrites it.

To further explain what's going on here:

$HOME refers to your home directory. On your machine, and if your user is called user, this would be /Users/user. This would vary based on the type of operating system you have and your username, therefore we use $HOME to be device-independent.

$PATH is where your shell looks for programs to execute when you type a command in the shell. If you do echo $PATH you can see its content. It could look something like this: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin. All the parts separated by : is a segment of the path, and your shell looks in each of those directories for a program that matches the command you gave.

Lyndseylyndsie answered 29/6, 2020 at 18:7 Comment(0)
H
13

Open Terminal and Type:
vim $HOME/.zshrc

After that, we need to edit that file!
Press command I

Now on a new line Type:
export PATH="$PATH:/YOUR_FILE_PATH/flutter/bin Don't forget to update YOUR_FILE_PATH!

Now press esc

Now type :wq! to exit

Now restart your terminal

Hashim answered 20/9, 2020 at 19:7 Comment(0)
K
5
source ~/.zshrc

Type this command in Terminal. This work for me.

Kelantan answered 1/8, 2021 at 6:29 Comment(0)
L
3

Remove the empty space in

export PATH="$PATH: /Users/user/Desktop/flutter/bin"
Luca answered 29/6, 2020 at 14:10 Comment(1)
This is work, but temporary solution, Thanks !!! – Semeiology
M
3

Open Terminal and Type:

vim $HOME/.zshrc

After that, we need to edit that file! Press command I

Now on a new line Type:

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

Don't forget to update YOUR_FILE_PATH!

Now press esc

Now type :wq! to exit

Now restart your terminal

Marvelofperu answered 6/12, 2022 at 1:56 Comment(0)
H
3

FolloW These Steps For Permanent Solution enter image description here

enter image description here enter image description here

enter image description here enter image description here enter image description here enter image description here

Hydroelectric answered 5/12, 2023 at 11:11 Comment(2)
Thanks man, finally I got it running!! 🀘🏼 – Ungrounded
That worked for me too. In the last step before running flutter please close and reopen the command prompt if needed. – Microscope
C
2

Try this one that is in the official documentation. https://docs.flutter.dev/get-started/install/macos

export PATH="$PATH:`pwd`/flutter/bin"
Carbolated answered 11/1, 2023 at 19:38 Comment(0)
V
1
export PATH=$PATH:/'Your Path'/flutter/bin\

example :- export PATH=$PATH:/Applications/Flutter/flutter/bin\

this is work for me

Vesuvianite answered 1/10, 2021 at 5:40 Comment(0)
C
1

Type this command in Terminal. This work for me.

export PATH="$PATH:`pwd`/flutter/bin"
Conradconrade answered 20/11, 2022 at 9:51 Comment(1)
OK, its working after executing this command. But why I need to do it every-time when running flutter command? – Paulinapauline
F
1

The .zshrc file is not present by default sometimes, we need to create it.

Steps for creation:

Open Terminal -> type touch ~/.zshrc to create the respective file.

To open the file -> type open $HOME/.zshrc

or

Open Finder > Press Cmd + Shift + ~

Fistulous answered 14/2, 2023 at 11:12 Comment(0)
G
0
  1. Open terminal

  2. Write => vim .bash_profile

    OR => vim $HOME/.zshrc

  3. Click on (i) to be able to insert the following:

    Write => export PATH="$PATH:[PATH_OF_FLUTTER_GIT_DIRECTORY]/bin"

    OR => export PATH=[PATH_OF_FLUTTER_GIT_DIRECTORY]/bin:$PATH

  4. Click on (esc) to be able back from inserting mode

  5. Write => :wq! [This will exit]

  6. Restart terminal then Write => flutter doctor

  • The problem will be easily solved ^_^
Gleda answered 6/7, 2022 at 22:25 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.