When using Flutter on macOS, developers might encounter the error zsh: command not found: flutter
even after updating the PATH as per the official Flutter documentation. This issue typically arises due to incorrect configuration of the .zshrc
file, which is crucial for the zsh shell to recognize the Flutter command. Resolving this error is essential for Flutter developers as it ensures a smooth development workflow, allowing them to efficiently build and run their applications without interruption.
The error “zsh: command not found: flutter” on macOS occurs when the terminal cannot locate the Flutter executable. This typically happens after updating the PATH variable according to Flutter’s official documentation but not applying the changes correctly.
.bash_profile
instead of .zshrc
, the changes won’t apply.source ~/.zshrc
) for the changes to take effect.Ensuring the PATH is correctly set in the appropriate shell configuration file is essential for a smooth development workflow. If you encounter this error, double-check your shell configuration and ensure the PATH is updated correctly.
Here’s a step-by-step guide to update the PATH for Flutter on macOS to avoid the ‘zsh: command not found: flutter‘ error:
Open Terminal.
Open the .zshrc
file:
nano ~/.zshrc
Add the Flutter bin directory to your PATH:
export PATH="$PATH:[PATH_TO_YOUR_FLUTTER_DIRECTORY]/flutter/bin"
Replace [PATH_TO_YOUR_FLUTTER_DIRECTORY]
with the actual path where Flutter is installed.
Save and close the file:
Control + X
to exit.Y
to confirm changes.Enter
to save.Apply the changes:
source ~/.zshrc
Verify the installation:
flutter doctor
This should resolve the issue and allow you to use Flutter commands in your terminal.
Incorrect Path Update:
.zshrc
file.Not Sourcing .zshrc
:
source ~/.zshrc
after updating the file, which means changes aren’t applied.Multiple Shell Configurations:
.bash_profile
instead of .zshrc
).Path Conflicts:
Verify Path Update:
.zshrc
file:export PATH="$PATH:/path/to/flutter/bin"
Source the Configuration:
.zshrc
, run:source ~/.zshrc
Check for Multiple Configurations:
zsh
, it should be .zshrc
.Validate PATH:
echo $PATH
Restart Terminal:
Check Flutter Installation:
which flutter
By following these steps, you should be able to resolve the zsh: command not found: flutter
error on macOS. If issues persist, double-check the Flutter installation and ensure there are no typos in the configuration files.
Open Terminal.
Check Flutter Path:
echo $PATH
Expected Output: Should include the path to Flutter’s bin
directory, e.g., /Users/your-username/flutter/bin
.
Verify Flutter Installation:
flutter --version
Expected Output: Flutter version details, e.g., Flutter 3.0.0 • channel stable • https://github.com/flutter/flutter.git
.
Check Flutter Doctor:
flutter doctor
Expected Output: Diagnostic information about your Flutter setup, indicating any issues that need to be addressed.
If all commands return the expected outputs, the error is resolved.
Follow these steps carefully and ensure you update your path according to the Flutter official docs.
Verify that you are editing the correct configuration file for your shell (e.g., .zshrc for zsh).
Check if the path is correctly set by running echo $PATH
and confirm there are no conflicts or duplicates.
Restarting the terminal can also help apply changes.
Finally, check Flutter installation by running which flutter
and verify that it returns the path to the Flutter executable.
If issues persist, double-check the Flutter installation and configuration files for typos.