简体   繁体   中英

zsh: command not found: flutter?

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?

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.

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

Remove the empty space in

export PATH="$PATH: /Users/user/Desktop/flutter/bin"
source ~/.zshrc

Type this command in Terminal. This work for me.

export PATH=$PATH:/'Your Path'/flutter/bin\

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

this is work for me

  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 ^_^

Type this command in Terminal. This work for me.

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

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM