Trouble with Terminal on MacOS Monterey

I just performed an upgrade on my Mac Pro 2020 with m1 chip, but I noticed I can’t use commands like mkdir or ls. When I do, I end up with “zsh killed” error. How do I fix this? I have removed ohmyzsh, and tried uninstalling homebrew

Posted on Jul 19, 2022 2:05 AM

Reply
Question marked as Top-ranking reply

Posted on Jul 19, 2022 9:54 AM

Johnson44uuu wrote:

Also, i tried booting into safe mode, same issue happens as well


Testing in Safe Mode is always a good idea.

In this case, it is not surprising that the problem remains, because as far as we can tell this has something to do with the shell settings, like that PATH going through /opt/... first.


We need to determine how these go into your PATH.


There is another way to put directories in the PATH: via /etc/paths and /etc/paths.d


Let's see if that is where the homebrew thing gets there.


In Finder, press Command-Shift-G and paste

/etc


Locate the file named "paths" in this folder. Control-click and choose Open With->TextEdit.

Do not make any changes to this file. What does it contain?


In Finder, press Command-Shift-G and paste


/etc/paths.d


What files does this folder contain?



Trying to avoid a reinstall of the OS.


23 replies
Question marked as Top-ranking reply

Jul 19, 2022 9:54 AM in response to Johnson44uuu

Johnson44uuu wrote:

Also, i tried booting into safe mode, same issue happens as well


Testing in Safe Mode is always a good idea.

In this case, it is not surprising that the problem remains, because as far as we can tell this has something to do with the shell settings, like that PATH going through /opt/... first.


We need to determine how these go into your PATH.


There is another way to put directories in the PATH: via /etc/paths and /etc/paths.d


Let's see if that is where the homebrew thing gets there.


In Finder, press Command-Shift-G and paste

/etc


Locate the file named "paths" in this folder. Control-click and choose Open With->TextEdit.

Do not make any changes to this file. What does it contain?


In Finder, press Command-Shift-G and paste


/etc/paths.d


What files does this folder contain?



Trying to avoid a reinstall of the OS.


Jul 19, 2022 9:13 AM in response to Johnson44uuu

Does the following work in Terminal, and if so, what is the result?


echo $PATH


Also: while we are trying to figure out the issue with zsh, you may want to try and see if other shells do work, like bash.


You can go to Terminal->Preferences->Profiles, duplicate your favorite profile and in the copy change the shell to bash.



Open a new window with that profile. Does it work?


Jul 19, 2022 10:41 AM in response to Johnson44uuu

Johnson44uuu wrote:

The paths.d folder, only contains my `go` text file, with this content
/usr/local/go/bin

Use the Finder to delete that file or move it somewhere else.


Then, create a new administrator account on your computer. From that account, you can "sudo zsh" or "su -l <old account>" (that's a lowercase L) and correct the startup files.


I can't tell you what you need to correct because I have no idea what Homebrew has done.

Jul 19, 2022 11:36 PM in response to etresoft

Well it didn’t work for me. sudo zsh, gave they same errors I was facing. Then I tried the other command, after which the same issue still persisted. I ended up doing a backup and reset to factory settings, so I could get back to work and not worry about this again.


Thank you very much for your time @etresoft and Luis. Really appreciate, hopefully someone else finds all this response helpful 🤗

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Trouble with Terminal on MacOS Monterey

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