The “Zsh command not found” is a pretty common error on Mac since the release of Catalina macOS, and this error also incorporates Zsh: command not found: brew, Zsh command not found: pip, Zsh: command not found: python, Zsh: command not found: nvm, Zsh: command not found: npm, and Zsh: command not found: jupyter, but the good thing is that there’s no need to be frustrated. You can fix this issue easily if you know all about its causes.
In this guide, we’re explaining why this error occurs and what you can do to resolve it in a few minutes. All the solutions we’re discussing are proven and have worked almost every time.
So, without any delay, let’s start!
Fix | Pros | Cons | Risky Level | Difficulty Level |
---|---|---|---|---|
Fix 1: Check the Command Spelling | Quick and straightforward. | Limited to fixing typos. | Low | Easy |
Fix 2: Verify the Command Is Installed | Identifies missing commands. | A bit tricky | Moderate | Moderate |
Fix 3: Check Your PATH | Resolves issues related to command location. | May require system-wide changes. | Moderate | Moderate |
Fix 4: Verify the Zsh Configuration | Addresses Zsh configuration issues. | Requires understanding of Zsh configuration. | Moderate | Moderate |
Fix 5: Reinstall Zsh | Resets Zsh to a clean state. | It’s a drastic measure | High | Moderate |
Fix 6: Install Xcode Command Line Tools | Essential for macOS users; resolves missing commands. | Specific to macOS and not relevant for other systems. | Moderate | High |
Fix 7: Set the Zsh Command Path in .zshrc | Explicitly sets command paths for Zsh. | Requires knowledge of essential directories. | Moderate | High |
Fix 8: Reinstall macOS | Comprehensive solution for persistent issues. | Loss of data, time-consuming, and involves reinstalling the entire operating system. | High | Moderate |
The Zsh (Z Shell) stands out as a widely embraced command-line shell among MacOS users. It lets users customize the shell environment to suit their individual preferences and requirements.
But sometimes, you may face a "Zsh command not found" error. It usually occurs when the Zsh shell cannot locate the command or executable you are trying to run.
Here are some common reasons for this error: If you are trying to run a command that is not installed on your system, Zsh will not be able to find it. As a result, you will see the “Not Found” pop-up. The PATH environment variable is a critical control that tells the shell where to look for executable files. If the directory containing the executable is not in your PATH, Zsh won't find it. Check your ~/.zshrc or system-wide configuration files for correct PATH settings. In most cases, Typos or misspellings can lead to the "command not found" error. Even a single letter or a space can cause the issue. Sometimes, people also double-press the keys unintentionally, which can lead to errors. Ensure that the command you are trying to run is a valid executable file. Sometimes, scripts or binaries may not have the correct permissions. You can use the ls -l command to check the permissions of the executable file. Furthermore, they may be corrupted, which can lead to errors. It usually happens during the installation. If the executable is in a non-standard directory, you should provide the full path to the command or add its directory to your PATH. Moreover, some commands are part of specific software packages. If the software is not installed or not included in your PATH, Zsh won't find the command. In some cases, configuration issues in your Zsh configuration files (~/.zshrc, for example) can lead to problems with locating commands. Therefore, it’s recommended to check for any errors or misconfigurations in these files. Moreover, if you're running a shell script directly and encountering this error, ensure that the script has the correct shebang line (e.g., #!/bin/zsh) at the beginning. You can try eight solutions to fix the “Zsh: Command Not Found” error. Note that each of these fixes doesn’t need much time. However, you must be careful, as even one incorrect step can jeopardize everything. As discussed above, one common reason for the "Zsh Command Not Found" error is a simple typo. Note that the system can't find what you're looking for if you don't use the right letters. Therefore, you should always double-check the command you entered.
If you didn’t misspell the command, then the next thing to do is verify whether the command package is even installed or not. You use your system's package manager to install it. For example, on Debian/Ubuntu systems, you can use: "sudo apt-get install example-package". In addition, you can visit the official website of the tool or command you need and follow their installation instructions. The PATH environment variable tells Zsh/Zrsh where to look for executable files. Therefore, you should focus on it, too, if you're facing the “Zsh: Command Not Found” error. Here’s what to do: Step 1. Start by viewing your current PATH. You can do this by typing “echo $PATH.” Step 2. After this, locate the command. Let's assume it's in “/path/to/your/command.” Step 3. Next, add “export PATH=$PATH:/path/to/your/command” and save it. Here’s another example of an export PATH:
Step 4. Lastly, restart your terminal or run source ~/.zshrc to apply the changes. Verifying the Zsh configuration can also help you fix the Command not found error. Doing this can ensure the system executes the command smoothly.
Step 1. Open your Zsh configuration file, usually located at ~/.zshrc. You can use a text editor like Nano, vim, or gedit. Step 2. After this, check for PATH settings. There, Ensure that your PATH variable is correctly configured. Look for lines similar to “export PATH=/some/directory:$PATH.”
Step 3. Then, verify any custom configurations. You should check for any custom configurations that might interfere with the system's ability to find commands. You can also comment out suspicious lines (add # at the beginning) and test. Step 4. After this, save the changes and restart the terminal. If you think the reason behind “Zsh: Command not found error” is that the Zsh is itself corrupted, then it’s better if you reinstall it. You can use the system’s package manager for this. Below is the image for Debian/Ubuntu and macOS with Homebrew:
Don’t forget to restart your Mac when you’re done. Certain commands may also depend on the Xcode Command Line Tools. Installing or updating them can resolve issues related to missing commands. Step 1. First, install Xcode command line tools. For this, open a terminal and run the following command: “xcode-select --install.” Step 2. A pop-up window will appear asking if you want to install the tools. Keep following the installation prompts.
Step 3. Next, wait for the installation. After this, you can retry the command. If the above solutions fail, you can also try setting the Zsh command path in the .zshrc file. It can fix the problem by helping with the execution of the command. Just follow these steps: Step 1. Open your Zsh configuration file, usually located at ~/.zshrc. Step 2. Next, Type nano /.zshrc Step 3. After this, you can add your $PATH variable information.
Step 4. Then, hit “Control + X.” After this, press Y and enter. Step 5. Now, save the changes and retry the command. If everything fails, you should reinstall MacOS to fix the issues. In fact, if you’re not tech-savvy and think the above solutions are too complicated, then you can try this solution as well. Step 1. Start by restarting your Mac and holding down Command + R until the Apple logo appears. Doing this will boot your device into Recovery Mode.
Step 2. Navigate and choose Disk Utility from the Utilities menu. You can use Disk Utility to erase your Mac's internal disk. Step 3. After erasing the disk, exit Disk Utility and choose "Reinstall macOS" from the Utilities menu. Simply follow the on-screen instructions to reinstall macOS.
Step 4. After the reinstallation, ensure that your system is up-to-date. You should also reconfigure your preferences and settings, including Zsh (if you are using it). Step 5. Finally, you can retry the command. But note that you will lose important files/data when you reinstall the MacOS. Therefore, you should also back up important files/folders before you do the solution. So, that’s all about how to fix the Zsh: Command Not Found error. There are higher chances that you will lose some of your files when you are reinstalling MacOS or trying any other solution. If you ever lose any data or files, then there’s no need to panic. We now have cutting-edge data recovery tools that can retrieve all the files within minutes. Out of all, the best one Mac users can use is AnyRecover. It’s an iMyFone data recovery software that can bring back all the deleted data with just a single click. That’s why it has received praise from leading Tech media outlets, including Engadget, PC World, Tech Radar, etc.
2,061,704 Downloads
AnyRecover can restore deleted data from over 2000 storage devices, even if there’s no Time Machine backup. It can retrieve files no matter how they were lost. Whether you were reinstalling macOS or simply deleted your data accidentally, this software can recover everything. The scanning and recovery speed is ultra-quick. You will have all of your data back within a few minutes. It uses top-tier AI to fix your corrupted files, including the ones that are causing the command issues. This software supports both the latest and older MacOS versions. It supports 1000+ formats, which means you won’t ever face compatibility issues (no matter for which reason you are using AnyRecover). Step 1:
Download and Install AnyRecover on your Mac and launch it. From different options, choose the "Data Recovery" mode.
Step 2: Select the deleted data type and begin the scanning. When the scanning is finished, you can also preview the lost data files.
Step 3: Select the files you want to restore or choose All. Then, click “Recover.”
How Do I Resolve a Command Not Found on Mac?
You can do many things to resolve the “Command not found” issue on Mac. The top ones are:
Part 2. 8 Proven Solutions to Fix Zsh: Command Not Found Error
Fix 1: Check the Command Spelling
Fix 2: Verify the Command Is Installed
Fix 3: Check Your PATH
Fix 4: Verify the Zsh Configuration
Fix 5: Reinstall Zsh
Fix 6: Install Xcode Command Line Tools
Fix 7: Set the Zsh Command Path in the .zshrc File
Fix 8: Reinstall the MacOS
Part 4. Bonus Tip: Recover Accidentally Deleted Data on Mac?
Features of AnyRecover
How to Recover Deleted Data on Mac?
Part 5. Zsh: Command Not Found FAQs
Why Does My Terminal Say Command Not Found?
The terminal usually says “Command not Found” due to spelling mistakes and incorrect path configuration. Sometimes, the system/software also needs an update.
Why Is Brew Command Not Found on Mac and How To Fix?
If you face "brew: command not found" on macOS, it means Homebrew (a package manager for macOS) is not installed or is not in your PATH. To fix this:
All-inclusive, the "Zsh: Command Not Found error" occurs when the Zsh shell cannot locate or execute the command. Fortunately, you can fix them by verifying your command is installed, setting the command path, reinstalling the MacOS, and doing several other solutions.
But note that you may also lose some files when you try to resolve the issue. Worry not! Whenever any file is lost or deleted, you can use AnyRecover Data Recovery Software to restore it. It can scan all the present and deleted files within a minute and retrieve them with a single click.
The best part? It supports 1000+ file formats, which means you can bring back any file/data you want.
AnyRecover Key features include:
Time Limited Offer
for All Products
Not valid with other discount *