how to fix “bash: flutter: command not found” error?

前端 未结 1 566
心在旅途
心在旅途 2021-01-23 17:36

I have been working on flutter using VScode with all environment variables set on Windows OS. Now i upgraded the flutter using \"flutter upgrade\" in Git Bash terminal of VScode

相关标签:
1条回答
  • 2021-01-23 18:17

    It's possible that the environment variable, that was previously set, got cleared at some point and that's why the Flutter command is not recognized.

    In any case, one way to make sure that Flutter is in your profile is to add it to your path within your ~/.bash_profile (bash profile) file. The ~/.bash_profile is a script gets executed every time you open Git Bash.

    Adding Flutter to your Bash Profile

    1. Open your ~/.bash_profile file for editing:
    $ nano ~/.bash_profile
    
    1. Add to the top of your ~/.bash_profile file, the following lines:
    # Add Flutter to PATH
    PATH=/path/to/flutter/bin:$PATH
    
    # Add Dart to PATH
    PATH=/path/to/flutter/bin/cache/dart-sdk/bin:$PATH
    

    Replace /path/to/flutter, with the absolute path of your Flutter installation directory.

    1. Apply the changes:
    $ source ~/.bash_profile
    

    Ensuring Git Bash is opened for non-login shells
    (Credit: Charles Duffy)

    $ echo "source ~/.bash_profile" >> ~/.bashrc
    
    0 讨论(0)
提交回复
热议问题