dwyl / learn-flutter

🦋 Learn how to use Flutter to Build Cross-platform Native Mobile Apps
https://flutter.dev
GNU General Public License v2.0
73 stars 8 forks source link

command not found: Flutter #27

Closed miguelmartins17 closed 1 year ago

miguelmartins17 commented 4 years ago

In order to access Flutter through the command line and need to change the path of the Flutter folder, I did so but Flutter is still not recognized.

Is there any way I could have just temporarily changed the path of Flutter?

nelsonic commented 4 years ago

@miguelmartins17 what Operating System are you using? When you open an issue requesting help from the community, always give as much information as possible.

There are a range of options for solving this obstacle: https://stackoverflow.com/questions/50652071/flutter-command-not-found

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

miguelmartins17 commented 4 years ago

@nelsonic I'm using Mac, I'll try to use those commands. Thanks, Nelson. 👍

miguelmartins17 commented 4 years ago

Even after changing the path of Flutter and even editing the _bashprofile when I close the terminal and reopen Flutter is no longer recognized. 😕

nelsonic commented 4 years ago

@miguelmartins17 the file name and location/path is important. Please run the following commands:

cat ~/.bash_profile | pbcopy

Then paste what you just copied into your next comment. e.g:

alias AndroidStudio="open -a /Applications/Android\ Studio.app"
alias as="open -a /Applications/Android\ Studio.app"
alias flutter="/Users/n/development/flutter/bin/flutter"
miguelmartins17 commented 4 years ago

@nelsonic I've already been able to access Flutter from the terminal and I've closed it and opened it again and it works.

I went to the documents and changed bash_profile right through the file, and now it works. Thanks a lot

miguelmartins17 commented 4 years ago

Can we close this issue now?

nelsonic commented 4 years ago

@miguelmartins17 we need to add it to a "troubleshooting" section of the README.md Similar to how we have in: setup-instructions.md#trouble-shooting-if-it-doesnt-work

That way other people in the community/team can understand how to fix the problem when they see it.

Tharun445 commented 4 years ago

even I have the same problem.. Tharuns-MacBook-Pro:~ tharun$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/tharun/Documents/\ Development /flutter/bin Tharuns-MacBook-Pro:~ tharun$ which flutter Tharuns-MacBook-Pro:~ tharun$ flutter --version -bash: flutter: command not found

flutterq commented 3 years ago

all possible working solution added [Solved] zsh: command not found: flutter

Standaa commented 2 years ago

@nelsonic I am really curious why you would need an alias for this? In my case I tried adding each of the following to my .zshrc:

export PATH=$PATH:$HOME:/Dev/flutter/bin
export PATH=/Users/standaa/Dev/flutter/bin:$PATH
export PATH=$PATH:/Users/standaa/Dev/flutter/bin
export PATH="$PATH:$HOME:/Dev/flutter/bin"
export PATH="/Users/standaa/Dev/flutter/bin:$PATH"
export PATH="$PATH:/Users/standaa/Dev/flutter/bin"

None of them work. I reloaded the shell each time, restarted iTerm, restarted my laptop and reinstalled the sdk to no avail.

I did the same thing then, pointing to the executables in the bin folder. It did not work either. All my other paths work fine and I followed the official docs.