'Flutter commands do not work in terminal on Mac OS after update

I am running on a Mac, I downloaded Flutter through Git and can confirm that the files are all there, I also successfully updated my path in my ~/.zshrc file. This was all working fine until I ran flutter upgrade, after which the flutter command stopped working. I confirmed this by running which flutter and the output was:

/Users/aamir/development/flutter/bin/flutter

which looks correct. However, running flutter in my terminal gives me back this error:

: command not foundpment/flutter/bin/internal/shared.sh: line 5: 

Not sure what's the issue here



Solution 1:[1]

The way I aliased the flutter command on Mac was by editing my ~/.bash_profile file:

vi ~/.bash_profile
Then add the lines:

alias flutter="/Users/n/development/flutter/bin/flutter" After you save the file (e.g: by typing [esc] :wq in Vim) run the "source" command to load the aliases into your current terminal session:

source ~/.bash_profile

Now the flutter command works in terminal e.g: flutter doctor, flutter test and flutter run

Ref: https://github.com/dwyl/learn-flutter/issues/27#issuecomment-583831888

Solution 2:[2]

For zsh:

For zsh (Apple M1):

   1.Open Terminal
   2.Run: nano ~/.zshrc
   3.Add: export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
   4.Run: source ~/.zshrc
   5.restart terminal
   6.Run: flutter doctor -v

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Paresh Mangukiya
Solution 2 Raj008