How to Solve Command Not Found in Flutter?

· 5 min read
Command Not Found
Command Not Found

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.

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 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 flutter\bin 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 flutter\bin 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 our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs, etc.

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.

Leave a Reply