You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Terminal issues

Dear users,

I was using my terminal and then suddenly I realised the .zshrc file is missing then it's not able to run commands like vi, less ....


The error message is:

zsh: command not found: vi


All the programs, which I installed via brew and conda are no longer available. I'm not sure what's going on. I listed bin issuing

%ls /bin/


and the output is:


[ dd launchctl pwd test

bash df link rm unlink

cat echo ln rmdir wait4path

chmod ed ls sh zsh

cp expr mkdir sleep

csh hostname mv stty

dash kill pax sync

date ksh ps tcsh


I wonder if you have any suggestions. I am using macOS Monterey, MacBook pro M1, 2020 and I'm happy to share any information you may need to solve this problem.


Many thanks in advance.

MacBook Pro 13″, macOS 10.13

Posted on May 12, 2022 6:54 AM

Reply

Similar questions

9 replies

May 12, 2022 7:46 AM in response to dancingatom

dancingatom wrote:

Dear users,
I was using my terminal and then suddenly I realised the .zshrc file is missing then it's not able to run commands like vi, less ....

The error message is:
zsh: command not found: vi

All the programs, which I installed via brew and conda are no longer available. I'm not sure what's going on. I listed bin issuing
%ls /bin/

and the output is:

[ dd launchctl pwd test
bash df link rm unlink
cat echo ln rmdir wait4path
chmod ed ls sh zsh
cp expr mkdir sleep
csh hostname mv stty
dash kill pax sync
date ksh ps tcsh

I wonder if you have any suggestions. I am using macOS Monterey, MacBook pro M1, 2020 and I'm happy to share any information you may need to solve this problem.

Many thanks in advance.




ref:

https://rocreguant.com/easy-install-anaconda-on-macos-using-homebrew/1875/



echo $PATH


PATH export statement in the $HOME/.bash_profile or $HOME/.zshrc file.


ref: None of the commands are working in my Te… - Apple Community





see if there is anything here: Keep getting "operation not permited" Ero… - Apple Community



May 12, 2022 8:43 AM in response to dancingatom

Start with creating a /Users/username/.zshrc file, as it is not present by default. In a plain text editor (/usr/bin/vi), enter the following information if on an Intel Mac using brew:


export PATH=".:$HOME:/usr/local/bin:${PATH}"
PS1="%m: %~ %% "




and the following if using an M1 Mac and brew (requiring the /opt location):


export PATH=".:$HOME:/usr/local/bin:/opt/homebrew/bin:${PATH}"
PS1="%m: %~ %% "



The ~/.zshrc file will be read each time you launch the Terminal application, and if you want the PATH setting applied in the current Terminal session:


source ~/.zshrc


With the above, you should have access to any executable that you have installed on the Mac, and these PATH settings may need to be modified per your Python installation instructions.


May 13, 2022 4:21 AM in response to VikingOSX

Hello there,


Thanks very much for your response.


As you suggested I tried

export PATH=".:$HOME:/usr/local/bin:/opt/homebrew/bin:${PATH}"
PS1="%m: %~ %% "

and

tried executing normal unix based commands but it is still not working

For example:

% vi test

zsh: command not found: vi

I tried using

source ~/.zshrc

but still same problem.


Any advice?


Many thanks in advance.


May 13, 2022 6:09 AM in response to dancingatom

Quit the Terminal application and relaunch it. Use /usr/bin/vi or /usr/bin/vim. Remember, if you are on an Intel box then homebrew uses /usr/local/bin, and on Apple Silicon, it wants to use /opt/homebrew/bin for installations and where it finds user installed commands.


Source is a Zsh or Bash shell built-in command and if it fails, then you are not finding the PATH to the shell, which should be /bin/zsh or /bin/bash for shells installed by the operating system. That /usr/bin and /bin are included in the default PATH variable.

May 14, 2022 2:04 PM in response to VikingOSX

Hello there,


Many thanks and sorry for my ignorance. Should I then set the following paths in a new .zshrc file in ~/ for all commands to work


/Users/dancingatom/opt/anaconda3/bin:/bin:

/Users/dancingatom/opt/homebrew/Cellar/openmotif/2.3.8_1:/opt/homebrew/bin:

/opt/homebrew/bin

/usr/bin/


Do you think this will work?


I can however see that in /usr/bin simple but important commands like cp, mv etc... are not available in /usr/bin/. It seems like some of these commands are in /bin/ therefore, shall then also put /bin/ in the path as well.


Thanks so much in advance.

May 14, 2022 2:28 PM in response to dancingatom

The PATH environment variable implicitly has /usr/bin:/usr/sbin:/sbin:/bin:/usr/local/bin, so the only redundancy would be certain to precede it with /usr/local/bin to make it first in the search process and thus, locate commands there first.


Follow the instructions the Anaconda Python recommends for their PATH setup. If you are not on an M1 Mac, then you can forget about the /opt/homebrew/bin location. If brew installed openmotif correctly, it would be in the appropriate brew bin location and not left in the Cellar. That openmotif has a monster hierarchy of dependencies that you can see with this command:


brew deps --tree --installed openmotif


I have aliased this command in my ~/.zshrc:


alias brew_deps='brew deps --tree --installed "$@"'



May 14, 2022 3:34 PM in response to VikingOSX

Thank you!


I put

export PATH="/usr/bin/"

and I can use vi and other commands but I can't use

"csh echo ksh mkdir rm sync zsh

bash dash ed launchctl mv rmdir tcsh

cat date expr link pax sh test

chmod dd hostname ln ps sleep unlink

cp df kill ls pwd stty wait4path"


conda seems to be in the path. I used the path set up from a backed up file for the former .zshrc file until recently brew command was working but it has stopped working now. I know that it is in /usr/local/Homebrew/bin/


Don't know what is going on ...



May 14, 2022 4:44 PM in response to dancingatom

Maybe you should print out the value in $PATH to see what it is. Sounds like you may not have the correct defaults in $PATH before .zshrc is processed so your $PATH is only contains the values you've added in the ~/.zshrc file. I tried looking for where macOS assigns the default $PATH value, but cannot locate it in the standard locations I'm familiar with on my Mac. I suggest creating a new admin user account, logging out your current user account, then logging into the newly created user account to print out the contents of the default $PATH to make sure it is correct. If it is incorrect, then you may have something major that is corrupt on your system.

echo  $PATH



May 17, 2022 1:48 PM in response to HWTech

Many thanks @HWTech and @VikingOSX


After the terminal when I found that even my photos stopped working too i.e., it wasn't able to find the library. I decided to reinstall the OS, which has fixed the problems of the terminal but didn't fix the issues with the photo library. It still says "The library could not be opened".... I'm now trying to fix this new issue.


Terminal issues

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.