zsh 'dotnet' command not found
Solution(s)
1. Download and install .NET (version 8 or 9)
Download and install .NET if you haven’t already.
Then close and reopen your terminal to test the command again.
2. Add the ‘dotnet’ path to your PATH using terminal
-
To add ‘dotnet’ to your PATH, run the following command:
Terminal window echo "export PATH=\"/usr/local/share/dotnet:\$PATH\"" >> ~/.zshrc -
Apply Changes
Save the
.zshrc
Reload the.zshrc
paths with the following command to apply changes immediately:Terminal window source ~/.zshrc
3. Add the ‘dotnet’ path to your PATH manually
-
Locate Your
.zshrc
FileThe
.zshrc
file is located in your home directory at~/Users/(your username)/
.If you don’t see it, press Shift + Command + . (dot) to toggle hidden files visibility in Finder.
-
Identify Your Username (Optional)
To ensure you’re in the correct directory, you can use the
whoami
command in Terminal to check your username:Terminal window whoami -
Add .NET Path to PATH
For .NET compatibility, add this line to your
.zshrc
file as well:Terminal window export PATH="/usr/local/share/dotnet:$PATH" -
Apply Changes
Save the
.zshrc
file and then reload it with the following command to apply changes immediately:Terminal window source ~/.zshrc
4. Update permissions
If you are still having issues, try following the steps on the 3. .zshrc permission issues page first, then come back to repeat the steps above.