Flutter command not found

前端 未结 30 1141
独厮守ぢ
独厮守ぢ 2020-11-29 16:54
bash: flutter: command not found

Apparently, none of the flutter commands are working on the terminal of an android studio which I believe I am tryi

相关标签:
30条回答
  • 2020-11-29 17:16

    You need to correctly set up your flutter path.

    from here https://flutter.dev/docs/get-started/install/macos#update-your-path

    1. Determine the directory where you placed the Flutter SDK. You will need this in Step 3.
    2. Open (or create) $HOME/.bash_profile. You can do that by using 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.

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

    1. press CTRL X and when it asked you to save the file, choose yes

    2. Run source $HOME/.bash_profile to refresh the current window or restart the terminal

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

    0 讨论(0)
  • 2020-11-29 17:16

    To those who still don't have the solution, it's because your path is wrong. Putting it in .bashrc or .profile works as long as your path is correct. Please check your flutter directory and see where the folder bin is located. mine looks like this

    export PATH=$HOME/flutter/flutter/bin:$PATH
    
    0 讨论(0)
  • 2020-11-29 17:17

    In macOS Catalina the default shell is Zsh. I did Following command on Terminal:

    1. nano .zsh (Will open command line editor)
    2. export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH"
    3. Save file by "Control" + "O" then Press "return"
    4. "Control" + "X" to exit
    5. Relaunch Terminal.
    6. echo $PATH
    0 讨论(0)
  • 2020-11-29 17:19

    In Mac, There are two options to solve this issue.

    Option 1: Adding the flutter SDK path permanently(it will work in any terminal session)

    Download the flutter SDK and extract in any location and then you have to add the below line in $HOME/.bash_profile file(hidden folder as default).

    export PATH="$PATH:[where flutter sdk downloaded and extracted]/flutter/bin"

    for eg:export PATH="$PATH:~/development/tools/flutter/bin"

    Option 2: If you are facing any difficulties with Option 1, then this is much simpler but you have to do this simple step whenever you restart your system/terminal.

    Step 1: Go to the path where flutter SDK downloaded and extracted (eg: cd ~/Development/tools/)

    Step 2: Enter this command

    export PATH='pwd'/flutter/bin:$PATH

    That's it. Type "flutter doctor" to check this issue gets resolved. Happy Coding.

    0 讨论(0)
  • 2020-11-29 17:21

    Ubuntu 16.04 :-

    I added the path correctly for Flutter, Java, Android Studio and Android SDK in .bashrc file , but when I run flutter doctor, the terminal returns

    flutter: command not found

    Solution :-

    So,first I had to always run ->

    sudo su

    then ->

    source /home/your_name/.bashrc

    Then run flutter doctor, it works fine.

    So everytime, If I want to run flutter doctor, I have to run these above 2 commands.

    Hope it helps :)

    0 讨论(0)
  • 2020-11-29 17:22

    In my case, I put that line export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH to both file .bash_profile and .bashrc (put it on the last line). After that, run source .bash_profile and source .bashrc. Now it's working!, even if you close the terminal.

    0 讨论(0)
提交回复
热议问题