Flutter commands not found using Bash or ZSH on Windows

577

The error message $'\r': command not found means that your script has Windows-style newline endings. I've encountered it often enough I now recognize on sight!

Convert /mnt/c/flutter/bin/flutter and any other bash scripts to Unix-style newlines and the problem should go away.

Share:
577
MaylorTaylor
Author by

MaylorTaylor

Updated on December 13, 2022

Comments

  • MaylorTaylor
    MaylorTaylor over 1 year

    I recently downloaded and setup the new Windows Terminal on Windows 10. It requires you to download Ubuntu and then install Windows Terminal (UWP); but once you do that, you have access to Bash in Windows.

    All of that is working correctly. I then setup ZSH (Oh-My-ZSH) and got that working fine. I can use ZSH to do git and npm commands but when I try and run any flutter commands I get errors. I also get the same errors when i switch my terminal over to bash.

    My .bash_profile has only 1 line in it:

    export PATH=$PATH:/flutter/bin
    

    I would love to get my flutter commands working in bash and zsh. But it currently only works in cmd.

    My bash files are located at C:\home\<username> and flutter is installed at C:\flutter

    I have also added export PATH=$PATH:/flutter/bin to my .zshrc file. (open ZSH, run nano ~/.zshrc)

    .ZSHRC file .zshrc file

    Flutter Doctor flutter doctor

    • Ryosuke
      Ryosuke over 4 years
      add export PATH=$PATH:/flutter/bin in your .zshrc file also.
    • MaylorTaylor
      MaylorTaylor over 4 years
      I updated the OP to show that I have in fact added the export path to my .zshrc file -- however, i get the exact same error
  • MaylorTaylor
    MaylorTaylor over 4 years
    This was the issue! Found an easy guide here