Zsh command not found flutter как исправить

Recently I updated Mac OS to latest Catalina and my terminal which is using zsh now start showing me following error: zsh: command not found: flutter It was working fine before update.

Recently I updated Mac OS to latest Catalina and my terminal which is using zsh now start showing me following error:

zsh: command not found: flutter

It was working fine before update.

Shadab K's user avatar

Shadab K

1,65016 silver badges25 bronze badges

asked Oct 15, 2019 at 18:16

Code Hunter's user avatar

Code HunterCode Hunter

9,43122 gold badges67 silver badges94 bronze badges

2

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 ~.

Basheer AL-MOMANI's user avatar

answered Nov 29, 2019 at 5:36

Murad Al Wajed's user avatar

Murad Al WajedMurad Al Wajed

3,7701 gold badge9 silver badges11 bronze badges

15

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

answered Jun 26, 2020 at 19:09

iamnagaky's user avatar

10

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

answered Aug 2, 2020 at 6:35

surhidamatya's user avatar

surhidamatyasurhidamatya

2,33133 silver badges56 bronze badges

3

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

answered Oct 15, 2019 at 19:08

Marcos Boaventura's user avatar

2

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

answered Aug 1, 2020 at 11:51

user3305074's user avatar

user3305074user3305074

6787 silver badges19 bronze badges

2

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

answered Sep 16, 2020 at 12:05

Mohammad Alotol's user avatar

2

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

Soroush's user avatar

Soroush

5414 silver badges17 bronze badges

answered Oct 27, 2019 at 17:11

MikeFranks's user avatar

1

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
    

Dharman's user avatar

Dharman

29.3k21 gold badges80 silver badges131 bronze badges

answered Nov 1, 2020 at 10:59

labr4t's user avatar

labr4tlabr4t

811 silver badge1 bronze badge

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

answered Mar 5, 2020 at 17:01

Yuri's user avatar

YuriYuri

3175 silver badges7 bronze badges

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

answered May 31, 2020 at 1:00

Abed Putra's user avatar

Abed PutraAbed Putra

1,0732 gold badges19 silver badges36 bronze badges

1

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.

answered Oct 16, 2019 at 5:45

Code Hunter's user avatar

Code HunterCode Hunter

9,43122 gold badges67 silver badges94 bronze badges

1

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.

answered May 18, 2020 at 11:33

Doan Bui's user avatar

Doan BuiDoan Bui

2,96222 silver badges33 bronze badges

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

answered Aug 4, 2020 at 10:52

zaffar's user avatar

zaffarzaffar

6696 silver badges13 bronze badges

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

answered Aug 10, 2020 at 16:05

devsandesh's user avatar

Recently I updated Mac OS to latest Catalina and my terminal which is using zsh now start showing me following error:

zsh: command not found: flutter

It was working fine before update.

Shadab K's user avatar

Shadab K

1,65016 silver badges25 bronze badges

asked Oct 15, 2019 at 18:16

Code Hunter's user avatar

Code HunterCode Hunter

9,43122 gold badges67 silver badges94 bronze badges

2

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 ~.

Basheer AL-MOMANI's user avatar

answered Nov 29, 2019 at 5:36

Murad Al Wajed's user avatar

Murad Al WajedMurad Al Wajed

3,7701 gold badge9 silver badges11 bronze badges

15

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

answered Jun 26, 2020 at 19:09

iamnagaky's user avatar

10

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

answered Aug 2, 2020 at 6:35

surhidamatya's user avatar

surhidamatyasurhidamatya

2,33133 silver badges56 bronze badges

3

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

answered Oct 15, 2019 at 19:08

Marcos Boaventura's user avatar

2

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

answered Aug 1, 2020 at 11:51

user3305074's user avatar

user3305074user3305074

6787 silver badges19 bronze badges

2

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

answered Sep 16, 2020 at 12:05

Mohammad Alotol's user avatar

2

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

Soroush's user avatar

Soroush

5414 silver badges17 bronze badges

answered Oct 27, 2019 at 17:11

MikeFranks's user avatar

1

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
    

Dharman's user avatar

Dharman

29.3k21 gold badges80 silver badges131 bronze badges

answered Nov 1, 2020 at 10:59

labr4t's user avatar

labr4tlabr4t

811 silver badge1 bronze badge

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

answered Mar 5, 2020 at 17:01

Yuri's user avatar

YuriYuri

3175 silver badges7 bronze badges

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

answered May 31, 2020 at 1:00

Abed Putra's user avatar

Abed PutraAbed Putra

1,0732 gold badges19 silver badges36 bronze badges

1

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.

answered Oct 16, 2019 at 5:45

Code Hunter's user avatar

Code HunterCode Hunter

9,43122 gold badges67 silver badges94 bronze badges

1

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.

answered May 18, 2020 at 11:33

Doan Bui's user avatar

Doan BuiDoan Bui

2,96222 silver badges33 bronze badges

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

answered Aug 4, 2020 at 10:52

zaffar's user avatar

zaffarzaffar

6696 silver badges13 bronze badges

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

answered Aug 10, 2020 at 16:05

devsandesh's user avatar

@abtisam

I have added path in .bash_profile but unfortunately, it doesn’t work. I have gone through multiple articles & stackoverflow post but nothing helps. Please suggest, how can I add this path permanently.
When ever I need to run flutter app I need to add path in terminal.
Given below is the complete .bash_profile

source ~/.bash_profile#export JAVA_HOME=$(/usr/libexec/java_home)
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export PATH=$PATH:/Users/air/Documents/development/flutter/bin

@stuartmorgan

@abtisam

@stuartmorgan I have used .zshrc and works fine. But I just need to understand one thing that I am working on mojave and according to the flutter docs, I used .bash_profile. Whereas, .zshrc is for Catalina.

@stuartmorgan

As the docs say (emphasis added):

Open (or create) the rc file for your shell. For example, Linux and Mac OS Mojave (and earlier) use the Bash shell by default

.zshrc is for zsh, not for Catalina specifically. If you are using a non-default shell on Mojave, then the default instructions for Mojave don’t apply to your case.

@Sarmed-armis

Dears i have same issue when i upgrade to catalina so how to solve that please

@abtisam

@amitmishra0807

@ErangaHeshan

For me removing double quotes did the fix.
Try changing export PATH="$PATH:~/development/flutter/bin" into export PATH=$PATH:~/development/flutter/bin

romainlq, CaicoLeung, and dinkuraja reacted with thumbs up emoji
remylavergne, chaiwutmaneechot, CaicoLeung, and mentoc3000 reacted with hooray emoji
junaid5546 reacted with confused emoji
meharbhutta, jay8t6, billklinton, vongkeo, zahin-mohammad, eduardo-aop, Kaushal0812, johncodeos, swaffoja, erwinleonardy, and 9 more reacted with rocket emoji

@CaicoLeung

For me removing double quotes did the fix.
Try changing export PATH="$PATH:~/development/flutter/bin" into export PATH=$PATH:~/development/flutter/bin

This worked for me

@lock

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@lock
lock
bot

locked and limited conversation to collaborators

Apr 19, 2020

No time to read?
tl;dr

  • When flutter is not recognized as a command, the application is most likely not part of your $PATH variable
  • To fix it, you need to append the bin directory of it to your $PATH variable
  • On Windows, do it preferably via GUI
  • On Linux und MacOS, put the following line in $HOME/.zshrc (or .bashrc respectively): export PATH="$YOUR_FLUTTER_DIR/bin:$PATH"

The flutter command is needed for every important action related to Flutter, such as:

  • Running the app
  • Updating the dependencies
  • Determining you installation’s status (flutter doctor)

However, if there is a problem with the executable, you might get the error:

1command not found: flutter

Let’s clarify the root cause of the error, what you need to know about the $PATH variable and how to debug the issue.

What does the error mean?

The error means a simple thing: your shell (bash, zsh or whatever shell you are using) is telling you that it looked into the $PATH, but could not find an executable named flutter.
Let’s say you downloaded Flutter and put it in a folder called “flutter” in your home folder ($HOME/flutter). You need to tell your shell to look right there for the executable file, as it doesn’t know by itself.

Where does the OS look for flutter?

Whenever you type a command — this can be any token you enter into your shell — the first thing the shell will do is to look inside its $PATH for an executable with the very name you have entered.
The important part is that there are a bunch of folders that are set by default, but if you want to make a new command available, you have to extend the $PATH variable by the new directory and thus tell it to look there as well.

Let’s look at how to set the path variable on different operating systems.

Windows

Under Windows, working with a shell is rather unpopular. Instead, most of the time, you work with the GUI of the OS. I will explain both ways, starting with the GUI:

GUI

  1. Using the keyboard shortcut Windows Key+X you access the Power User Task Menu.
  2. Select the System option.
  3. Scroll down and click About.
  4. Click the Advanced System Settings text button at the bottom of Device Specifications.
  5. Click the Advanced tab, then click the Environment Variables button near the bottom.
  6. Choose the Path variable in the System Variables area and click the Edit button. There you may add or modify the path lines with the paths you want the OS to access. Separate the paths with a semicolon.

CLI

If you prefer to set such options via the CLI, you can do this with a simple command: setx.

You need to run this from a privileged CLI.

To do that, right-click the cmd shortcut (e. g. Windows Key and then enter “cmd”) and select “Run as Administrator”.

If your Flutter directory is C:DownloadsFlutter, you need to set it like this:

1setx /M PATH "%PATH%;C:DownloadsFlutterbinflutter"

Using /M as an option will perform the change of PATH in HKEY_LOCAL_MACHINE instead of HKEY_CURRENT_USER, which makes it a system wide change and not only a user change.

setx truncates the stored path string to 1024 bytes (which equals to 1024 characters). This can lead to data loss if the path is already about 1024 bytes or longer!
If you are unsure, use echo %PATH% to read it beforehand.

Linux (with zsh)

On Linux distributions, there is unlike Windows not only one single source of truth. Instead, there is a defined order at which the OS sources files on booting up, that can alter the $PATH.
Some files are sourced under different circumstances, so it’s good to know, when to modify which one.
The files are sources in the following order:

1. /etc/zshenv / $HOME/.zshenv

(Always sourced)

.zshenv is sourced in any case. If environment variables are set there, then it should be ones that are updated frequently. It’s also used for exported variables that are suppoed to be read by other applications like $EDITOR, $PAGER and the one we’re interested in: $PATH.

Keep in mind that this file is sourced even when zsh is started to run a single command, also by other programs e. g. make. You should know what you’re doing as you can break the standard commands.

.zshenv also allows you to specify a new location for the rest of the zsh config. You can do this by setting $ZDOTDIR.

2. /etc/zprofile /$HOME/.zprofile

(Sourced at login)

Since .zprofile is used for login shells, it’s usually only sourced once. It’s basically an alternative to .zlogin (which is sourced two steps after) that should be rather used for variables that are not updated that frequently.

Lines they contain are only executed once, at the beginning of your login session.

If you make changes to this file and want to apply the configuration immediately, you can do this by running a login shell:

3. /etc/zshrc / $HOME/.zshrc

(Sourced in interactive shell)

This is probably the file you will change most of the time because it affects your interactive shells.
It’s often used for things such as:

  • Aliases
  • Key bindings
  • Output colors
  • Shell command history
  • Setting the $PATH variable

4. /etc/zlogin / $HOME/.zlogin

(Sourced at login)

Similar to .zprofile read at login, but sourced after .zshrc if the shell is not only login but also interactive.

5. /etc/zlogout / $HOME/.zlogout

(Sourced at logout)

Like the name implies, it’s called when logging out within the login shell. Can be used for clearing the terminal.

Conclusion

To solve the issue on Linux, put the following line in $HOME/.zshrc where $YOUR_FLUTTER_DIR is the directory where you downloaded Flutter:
export PATH="$YOUR_FLUTTER_DIR/bin:$PATH".

If you’re working e. g. with bash, you put it in the respective equivalent (.bashrc) instead.

MacOS (Catalina and newer)

MacOS behaves quite similar to Linux distributions. However, there are slight differences.
Let’s examine those by having a look at the execution order:

1. /etc/zshenv / $HOME/.zshenv

(Always sourced)

Same behavior as the Linux pendant

2. /etc/zprofile /$HOME/.zprofile

(Sourced at login)

Basically the same behavior as the Linux pendant. But there is a slight difference in the /etc/zprofile:

Which is the system-wide equivalent of the .zprofile of the user.

Its content looks like this:

1# System-wide profile for interactive zsh(1) login shells.
2
3# Setup user specific overrides for this in ~/.zprofile. See zshbuiltins(1)
4# and zshoptions(1) for more details.
5
6if [ -x /usr/libexec/path_helper ]; then
7 eval `/usr/libexec/path_helper -s`
8fi

Now what is the path_helper? Well, let the man page give us the answer:

The path_helper utility reads the contents of the files in the directories /etc/paths.d and /etc/manpaths.d and appends their contents to the PATH and MANPATH environment variables respectively.

man page of path_helper

So apparently, this program only concatenates the content of /etc/paths.d and /etc/manpaths.d which in my case only contains /Library/Apple/usr/bin.

3. /etc/zshrc / $HOME/.zshrc

(Sourced in interactive shell)

Basically the equivalent of the Linux pendant.

4. /etc/zshrc_Apple_Terminal

(Sourced in interactive shell)

This gives the terminal app of MacOS zsh support.

5. /etc/zlogin / $HOME/.zlogin

(Sourced at login)

Same behavior as the Linux pendant.

6. /etc/zlogout / $HOME/.zlogout

(Sourced at logout)

Overview

Here is an overview of the above explanation. The rows in the table represent the order of execution.

system-wide user login shell interactive shell scripts
/etc/zshenv $HOME/.zshenv x x x
/etc/zprofile $HOME/.zprofile x
/etc/zshrc $HOME/.zshrc x
/etc/zshrc_Apple_Terminal x
/etc/zlogin $HOME/.zlogin x
/etc/zlogout $HOME/.zlogout x

system-wide lists the files that affect all users, users the respective files that only affect the current user.

The overview also describes, which of the files is sourced when opening a login shell, an interactive shell or before a script execution:

Conclusion

Like on Linux, put the following line in $HOME/.zshrc where $YOUR_FLUTTER_DIR is the directory where you downloaded Flutter:
export PATH="$YOUR_FLUTTER_DIR/bin:$PATH".

Debugging the $PATH

If you want to know, what’s currently inside your $PATH variable, you can just print out its value.

Windows: echo %PATH%
Linux and MacOS: echo $PATH

Putting it all together

Command not found: flutter has simple root cause: flutter as a binary is not in a directory where your operating system looks for it.

In order to make it work, you have to add the location of your flutter binary to the $PATH variable of your operating system.

On Windows, you can do it via GUI or CLI.

On Linux and MacOS, add or update

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

to your .zshrc or .bashrc.

If you’re unfamiliar with editing hidden text files: just enter nano ~/.zshrc, change the line, press CTRL+X to close and Y to override. Re-source the file by entering source ~/.zshrc.

When the user installs and configures Flutter For the First time, when the user runs a command on a terminal, the user gets an error like Command Not Found. So in this article, we will go through How to Solve Command Not Found in Flutter.

You need to correctly set up your flutter path from here https://flutter.dev/docs/get-started/install/macos#update-your-path

  • Determine the directory where you placed the Flutter SDK. You will need this in Step 3.
  • Open (or create) $HOME/.bash_profile. You can do that by using a terminal text editor by going in the terminal and typing nano ~/.bash_profile

macOS Catalina uses the Z shell by default, so edit $HOME/.zshrc.

If you are using a different shell, the file path and filename will be different on your machine.

  • Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY] to be the path where you cloned Flutter’s git repo:
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH

for example:

export PATH=~/Documents/flutter/bin:$PATH
  • Press CTRL X and when it asked you to save the file, choose yes
  • Run source $HOME/.bash_profile to refresh the current window or restart the terminal
  • 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 ~/.bash_profile

Hence, directly add it to the path file permanently like below.

sudo nano /etc/paths

add this to the file

/Users/yourUserName/Development/flutter/bin
Users can try the below things
  • Download the Flutter SDK from Flutter SDK Archive
  • Extract it where do you want (for example/home/development/flutter)
  • Set your PATH, edit your file with this command gedit ~/.profile, you need to add this line
export PATH=[location_where_you_extracted_flutter]/flutter/bin:$PATH

So our export will look like this

export PATH=/home/myUser/development/flutter/bin:$PATH
  • Save the file and close it.
  • Run source ~/.profile to load the changes
  • If you run now flutter doctor should work!

If you are using zsh, you need to follow the below steps in mac.

  • Download the latest flutter from the official site.
  • Unzip it and move to the $HOME location of your mac.
  • Add to the path via .zshrc file
  • run nano ~/.zshrc into iTerm2 terminal.
  • export PATH=$HOME/flutter/bin:$PATH
  • Save and close ~/.zshrc file.
  • re-start iTerm2
  • Now you will have Flutter available.

Do this to add Flutter permanently to your path in Ubuntu :

cd $HOME
gedit .bashrc
  • Append the line:
    export PATH="$PATH:[location_where_you_extracted_flutter]/flutter/bin"

    in the text file and save it.

  • source $HOME/.bashrc

    Open a new terminal and run the flutter doctor command

Flutter SDK can run on Windows as well as macOS

For Windows

  • First, download the latest SDK from the flutter download page.
  • Now to run flutter in the windows console you need to update your PATH environment variable.
  • From the Start search bar, type ‘env’ and select Edit environment variables for your account.
  • Under User, variables check if there is an entry called Path.

1. If the entry does exist, append the full path to flutterbin using as a separator from existing values.

2. If the entry does not exist, create a new user variable named Path with the full path to flutterbin as its value.

For Mac

  • First, download the latest SDK from the flutter download page
  • Extract the file in the desired location using the following commands :

1. cd ~/development
2.unzip ~/Downloads/flutter_macos_v1.5.4-hotfix.2-stable.zip

  • Add the flutter tool to your path:

1.export PATH=”$PATH:`pwd`/flutter/bin”

Run flutter doctor

For Linux: To remember flutter commands permanently:

  • open up terminal and cd to $HOME. for eg: [email protected]:~$
  • open the hidden file .bashrc with your desired editor. It resides in $HOME.eg. sudo gedit .bashrc
  • add the following line export PATH=/home/username/flutter/bin:$PATH somewhere as a newline in .bashrc file preferably as the last line edit & save the file.
  • Run source /home/yourname/.bashrc in terminal to process your recent changes.
  •  Finally, run echo $PATH to see flutter dir is in your system path along with other such paths for eg: /home/username/flutter/bin

Conclusion:

So in this article, we have learned about how to Solve Command Not Found in Flutter.

Thanks for Reading!!! Keep Fluttering.

Do let us know if you need any assistance with Flutter Development?

Flutter Agency is one of the most popular online portals dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.

Frequently Asked Questions (FAQs)

1. Which coding is used in Flutter app development?

Flutter code compiles to the ARM or Intel machine code and JavaScript for fast performance on any device.

2. What is the main objective of Flutter?

Flutter is Google’s portable UI toolkit for developing beautiful, native compiled mobile, web, and desktop apps from a single codebase. Flutter will work with free and open-source code being used by Flutter developers and organizations worldwide.

3. How do you fix Flutter if it is not identified as an internal or external command?

Go to my computer programs>advanced system setting>environment variables. In this manner, you can solve Flutter, which is not recognized as an external or internal command issue in the windows operating system

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Zota электрокотел ошибка h8
  • Автокад как изменить горячие клавиши
  • Zota lux коды ошибок
  • Автокад как во всей таблице изменить стиль текста
  • Zota gsm ошибка h 6

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии