
zsh: command not found command-name
This is the most common error when you execute a command on the zsh shell if,
- Executed command is invalid.
- Executed command is misspelled.
- The command is valid but command package not installed.
- The command package is installed not set in $PATH environment.
- The command path is not set in the .zshrc file.
Let's see some examples of each of them,
Example 1: Executed command is invalid
% cls
zsh: command not found: cls
As you may have noticed cls is not a command to clear the screen on a Unix/macOS/Linux based Operating System. The correct command is clear, hence the command not found here is due to an invalid command.
Example 2: Executed command is misspelled
% gerp 'myfile.txt'
zsh: command not found: gerp
The command is misspelled, the correct spelling for the command is grep
Example 3: The command is valid but command package not installed
% brew
zsh: command not found: brew
brew is a valid command, but here the problem is that the package brew is not installed. In order for this command to work you need to install the package first.
How to fix: brew command not found.
Example 4: The command package is installed not set in $PATH environment.
% mvn
zsh: command not found: mvn
If you have an external package installed, it needs to set in the $PATH environment variable. If you do not do that and run the command from location away from the package installation you will again get command not found error.
Article: How to set $PATH variable
Example 5: The command path is not set in the .zshrc file.
% brew
zsh: command not found: brew
You must have noticed that as soon as you exit your Mac Terminal, the environment variable such as $PATH is not available. The $PATH was available until the Terminal session was active, but soon as it was terminated, we do not have access to the variable. In order to set the $PATH variable permanently, you would need to set it in the .zshrc file (Z-Shell resource file).
How to add $PATH in .zshrc file?- Open Terminal,
- Make sure you are on Zsh Shell, if not type zsh and hit enter,
- Now type nano ~/.zshrc
- Now add your $PATH variable details: Example: export PATH="$PATH:/opt/homebrew/bin/"
- Press Control + X, followed by Y to save the file, press enter to exit Nano,
- Now type command source ~/.zshrc to apply changes.
Have Questions? Post them here!
- Ubuntu zsh: command not found: nano
- Setting up Zsh Syntax Highlighting
- Fix for zsh: command not found: brew
- Fix - zsh: command not found: conda [macOS]
- Resolve - zsh: command not found: code
- How to make zsh as the default shell on Ubuntu
- zsh: exec format error eclipse M1 Mac
- [fix] zsh: illegal hardware instruction python TensorFlow M1/M2 Mac
- Fix zsh: permission denied: script.sh
- zsh: command not found [fix] macOS
- How to enable Auto-Save Files in VS Code - HowTos
- Git Remove Untracked Files using Command - Git
- How to Update Microsoft Teams to the latest Version - Teams
- How to know the MAC address of iPhone/iPad Wifi - iOS
- Microsoft Teams: Sign-in is blocked error - Teams
- Multiline EditText in Android Example - Android
- Get List of all local branches git command - Git
- [Fix] Microsoft Store Error Code: 0x803F8001 - Microsoft