Search code examples
bashflutterzshwindows-subsystem-for-linux

Flutter commands not found using Bash or ZSH on Windows


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


Solution

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