How to Fix Zsh Command Not Found Error on macOS [5 Ways] - Qiling  

5 Proven Ways to Fix Zsh Command Not Found Error on macOS [Bash & Zsh]


In 2019, macOS released Catalina, and from then on, Mac switched from Bash to Zsh as the default login shell. So, some Zsh commands might not be accessible after the system update. Users of macOS Catalina or higher versions like Big Sur, Monterey, and Ventura may get a message such as Zsh: command not found as we will discuss next, and other Zsh: command not found errors include Zsh: command not found: brew, Zsh command not found: pip, Zsh: command not found: nvm, or Zsh: command not found: npm. There are several reasons why this error might happen.

Zsh Errors

The Reasons for Zsh Command Not Found Error on Mac

While using Unix, Linux, or macOS, many people encounter this "Zsh command not found" issue. Users continue to search on forums for an answer to it. Therefore, we opted to offer all possible solutions to this problem. First, "Zsh: command not found" is most frequently caused by these reasons:

1. Misspelled Zsh commands on MAC

When using Zsh commands on Mac for the first time, users typically make mistakes like adding extra symbols or failing to include a space where it is needed. The wrongly spelled command is not readable for macOS. Thus, it would remind you of the command error. If you encounter the "zsh command not found" problem, ensure the command is correct.

Correct Spell

2. The command is valid, but the package is not installed

Users frequently attempt to perform an order, but the necessary package is not installed, so they will get the message "Zsh command not found". When the command is valid and correctly spelled, users had better determine whether they have installed the necessary package.

3. The change of default environment configuration of the Zsh command

Since macOS updates to new versions, the typical environment of orders varies, where most Linux bash commands store but are unsuitable for Zsh commands. Because, by default, Zsh does not read the environment variables from the previously specified address.

How to Fix Zsh Command Not Found Error With 5 Solutions

The Zsh: command not found issue on a Mac can occur in several different situations. You may get the message on macOS Monterey or any other macOS version that uses z-shell.

If you still have questions about fixing the error, please continue to read the solutions below.

Solution 1. Check the Syntax When Zsh Command Not found

When using Mac's Terminal and receiving the "Zsh: command not found" message, you should first look at the command's syntax. It's better to copy the original content into the Terminal than manually type it. Additionally, it will be helpful to compare your command with other examples that use the same command.

Solution 2. Ensure the Package of the Zsh Command Is Installed

You frequently try to perform a command, but the necessary package is not installed. If your command is valid and correctly spelled, does that mean you need to check to see if the required package is installed? The answer is no. Ensure you didn't forget to install the command's package on your Mac when you know the Zsh command is not found.

Solution 3. Set $Path Environment to Fix Zsh Command Not Found

To resolve the Zsh: command not found error, the second fix is to verify that the "$PATH" environment variable is configured correctly.

If you've installed the package but are still receiving the "Zsh: command not found error," something is wrong. It indicates that you need to create a PATH variable for your command package.

Here is an example of setting an export PATH:

Environment Variable

Most packages automatically set the path variable in macOS update or clean install. When performing a custom installation, you might occasionally need to set up path variables in Linux or macOS manually.

Solution 4. Set the Zsh Command Path in the .zshrc File

When you exit and re-login to the Terminal after installing the package and setting up the path variable, but still see the error Zsh command not found. Configure the command path in the .zshrc file to make it proper.

Your .zshrc file will run and set the command path each time you close and reopen the Terminal. To edit the .zshrc file, follow these steps.

Step 1. Open the macOS terminal.

Step 2. Verify that you are using the Zsh Shell; if not, type zsh and press the Enter key to check.

Step 3. Type nano /.zshrc on the window.

Step 4. Add your $PATH variable information now

zshrc macOS

Step 5. To save the file, hit Control + X, Y, and enter to close the Nano editor.

Step 6. To commit changes, execute command source /.zshrc now.

Solution 5. Reinstall the macOS to Fix the Zsh Command Not Found

You might have unintentionally deleted the files required for Terminal commands if you were rooting around in the macOS and happened to destroy specific system files or folders. You should then recover deleted files on Mac if that occurs.

To reinstall macOS without formatting the drive will allow you to go back to previous settings and fix the Zsh command not found. Although reinstalling the operating system shouldn't result in data loss, creating a backup of the crucial files is still advisable first. If you can't find your important data, try to recover files after reinstalling macOS.

Additional Information: How to Recover Deleted Data on Mac

As we mentioned in Solution 5, reinstalling macOS can be a helpful method to fix your Zsh command not found error. But additionally, restoring deleted files on Mac after reinstalling or updating is also vital.

It would be beneficial if you were attentive to protecting your data because incorrectly updated processes or wrongly commanding could result in losing your files and data. Here's an excellent tool for data recovery on your Mac: Deep Data Recovery for Mac.

Check the steps and learn how to use the software to recover deleted files on your Mac.

Step 1. Select file types

Launch Deep Data Recovery software. Select file types and click "Next" to start

Select file types that you want to recover

Step 2. Select the location and scan

Choose the disk where you lost data. Then, click "Scan" to start scanning.

select a location and click search for lost files

Step 3. Filter and preview lost files

After the scan, use the file format filter on the left or upper right corner to find the deleted files you need.

click recover to recover lost data

Step 4. Recover lost data or files

You can double-click a file to preview its content, or choose multiple files to recover them at once. Click "Recover" to restore the lost data to a local or cloud drive.

To Wrap It up

Overall, the "Zsh command not found" issue is brought on by the differences between the bash shell and the Zsh shell. Different versions of macOS could not match in complete compatibility. If you have just updated your Mac and found out that your Zsh command occurs problems, we hope the solutions below may help you. Additionally, your Mac devices might function effectively to safeguard your data with Deep Data Recovery for Mac.

Zsh Command Not Found FAQs

Here, we included 4 questions that you may also be interested in. Check and find the answers here.

1. Is Zsh default on Mac?

After macOS Catalina, zsh is the default on Mac. But on the macOS versions lower than Catalina, Zsh is not the default command shell on Mac.

2. How do I start Zsh on Mac?

Open the "Shell" tab - click "Run command" - type "zsh".

3. How to open the Zsh terminal on Mac?

4. How do I fix macOS's "Zsh: command not found brew" error?

Ensure you have installed the brew right and the path variable is set up correctly.

Related Articles


Is this information helpful?     

What can we do to improve this information? (Optional)
Refresh Please enter the verification code!