'Error everytime I open Terminal I get "zsh: command not found"

Even basic commands like 'pwd' or 'ls' I get the same error message. I'm completely lost, been looking across all websites looking for a solution. I've found commands that temporarily fix the problem like "PATH=/bin:/usr/bin:/usr/local/bin:${PATH} export PATH"

but as soon as I close and start a new terminal the same issue happens again when I reopen it. Please help.



Solution 1:[1]

It seems like your PATH (where all your commands are located) has been corrupted. Could you perhaps try echo $PATH to see whether it is what you expect?.

If it is not, you may want to have a look at your zshrc for any suspicious lines. You can do so with: open -a TextEdit ~/.zshrc

If this gives you an error, you hay have to do: touch ~/.zshrc first.

Delete the lines you think may be causing the problem.

For a quick fix, add PATH=/usr/bin:/bin:/usr/sbin:/sbin to the end of your zshrc that you just opened using TextEdit. This will reset the PATH variable to the macOS default.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 adisidev