
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!
- [fix] zsh: illegal hardware instruction python TensorFlow M1/M2 Mac
- macOS Ventura 13: The default interactive shell is now zsh
- Fix: cd: string not in pwd
- How to reload Zsh .zshrc Profile
- Resolve - zsh: command not found: code
- Ubuntu zsh: command not found: nano
- Fix: zsh: command not found: mysql (Mac XAMPP)
- Setting up Zsh Syntax Highlighting
- Fix zsh: permission denied: script.sh
- Fix - zsh: command not found: conda [macOS]
- zsh: command not found [fix] macOS
- ZSH: exec format error eclipse M1/M2 Mac
- Fix for zsh: command not found: brew
- Fix: zsh: command not found: npm after installation (Node.js)
- How to reload zsh shell profile file?
- How to Add New Entry to ZSH PATH
- How to make ZSH as the default shell on Ubuntu
- How to fix: zsh: command not found: jupyter
- How to clear ZSH history of commands executed on Mac Terminal
- Fix - zsh: command not found: pip
- Fix - cd: no such file or directory: .zshrc
- Add Syntax Highlighting in Zsh Shell
- Fix: ZSH: cd: too many arguments (macOS)
- Jupyter Notebook: 500 Internal Server Error - nbconvert failed: xelatex not found on PATH - Python
- Convert String Date to Date Object in Java - Java
- How to turn off Stage Manager - macOS Ventura - MacOS
- Read a file line by line in Python Program - Python
- JDBCTemplate Querying Examples with Spring Boot 3 - Java
- Display ls command file sizes in KB (kilobytes) MB (megabytes) or GB (gigabytes) [Linux/macOS] - MacOS
- Change Title text for Android Activity using java code - Android
- Java JDBC Connection with Database using SSL (https) URL - Java