zsh: command not found: flutter?

10,351

Solution 1

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

Solution 2

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.

Solution 3

Remove the empty space in

export PATH="$PATH: /Users/user/Desktop/flutter/bin"

Solution 4

source ~/.zshrc

Type this command in Terminal. This work for me.

Share:
10,351
giannik28
Author by

giannik28

Updated on June 13, 2022

Comments

  • giannik28
    giannik28 almost 2 years

    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?

    • JideGuru
      JideGuru almost 4 years
      You should restart your terminal and try again
    • chepner
      chepner almost 4 years
      PATH is colon-separated, not colon+space-separated.
  • Shrikant Tanwade
    Shrikant Tanwade over 2 years
    This is work, but temporary solution, Thanks !!!