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!
- Resolve - zsh: command not found: code
- zsh: command not found [fix] macOS
- How to fix: zsh: command not found: jupyter
- How to make ZSH as the default shell on Ubuntu
- How to Add New Entry to ZSH PATH
- Add Syntax Highlighting in Zsh Shell
- Fix: zsh: command not found: npm after installation (Node.js)
- Fix: zsh: command not found: mysql (Mac XAMPP)
- Ubuntu zsh: command not found: nano
- Fix: ZSH: cd: too many arguments (macOS)
- Fix - cd: no such file or directory: .zshrc
- How to reload zsh shell profile file?
- Fix zsh: permission denied: script.sh
- [fix] zsh: illegal hardware instruction python TensorFlow M1/M2 Mac
- macOS Ventura 13: The default interactive shell is now zsh
- How to Add Autocomplete in Mac Terminal
- Fix - zsh: command not found: pip
- ZSH: exec format error eclipse M1/M2 Mac
- Setting up Zsh Syntax Highlighting
- How to reload Zsh .zshrc Profile
- zsh: command not found: brew [fix]
- How to clear ZSH history of commands executed on Mac Terminal
- Fix - zsh: command not found: conda [macOS]
- Fix: cd: string not in pwd
- Fix Power BI error Access to the resource is forbidden when connecting SharePoint Online List as data source - SharePoint
- How to reset Eclipse IDE Code Font - Eclipse
- Java 8 Supplier Functional Interface Examples - Java
- Fix: error: non-static type variable T cannot be referenced from a static context - Java
- How to turn off Stage Manager - macOS Ventura - MacOS
- 🎃 Halloween Hashtag 2022 on Social Media 🎃 - Hashtags
- 25: How to rename a file using Python Program - Python-Programs
- Java Stream Word Count Example - Java