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

Jaden updated on Jan 11, 2024 | Home >Computer Instruction

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.

Before starting the 5 solutions, you might watch the following tutorial video first about the method for fixing the Zsh command not found error.

  1. 00:00 - Introduction
  2. 00:40 - Check if the Terminal is Zsh or bash
  3. 01:08 - Download mysql server for Mac
  4. 02:51 - Create .zprofile
  5. 04:15 - Configure path for mysql
  6. 05:00 - Use mysql-u root-p

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

  1. 1. Check the Syntax
  2. 2. Ensure the Package Is Installed
  3. 3. Set $Path Environment
  4. 4. Set Path in the .zshrc File
  5. 5. Reinstall the macOS

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, especially Mac Trash recovery on your Mac: EaseUS Data Recovery Wizard for Mac

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

Note: You can create a backup of your Mac by clicking the "Disk Backup" on the left first. The software will recover the deleted files from the backup image. It can prevent further damage to your disk and data, making it safer and more reliable.

Step 1. Select the location and scan

Launch EaseUS Data Recovery Wizard for Mac and choose the disk where you lost data. Then, click "Search for lost files" to start scanning.

select a location and click search for lost files

Step 2. 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.

filter lost files in types

Step 3. 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.

click recover to recover lost data

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 EaseUS Data Recovery Wizard 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?

  1. Step 1. Click the Launchpad icon in the Mac's Dock
  2. Step 2. Search "Terminal" in the field
  3. Step 3. Click Terminal.
  4. Step 4. Type "Zsh" to launch it.

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.

  1. Step 1. Open the .zshrc file with the command nano /.zshrc.
  2. Step 2. Add the following code to the file: export PATH="$PATH:/opt/homebrew/bin/"
  3. Step 3. Save the file using Control + Enter and X.
  4. Step 4. To apply changes, type source /.zshrc in the command line.

Was This Page Helpful?

 

Updated by Jaden

Jaden is one of the editors of EaseUS who lives and works in Chengdu, China. She focuses on topics concerning PCs and Mac data recovery. Jaden is committed to enhancing professional IT knowledge and writing abilities. She is always keen on new and intelligent products.

Read full bio

Totalav antivirus software

EaseUS Data Recovery Services

Request a free evaluation >>

EaseUS data recovery experts have uneaqualed expertise to repair disks/systems and salvage data from all devices like RAID, HDD, SSD, USB, etc.