1

I uninstall homebrew on a Mac Mini M1 to reinstall it.

After opening a terminal to run the install shell script, the terminal produces the following output and becomes unusable.

[Command not found: /usr/local/bin/zsh]

[Could not create a new process and open a pseudo-tty.]

I have logged into recovery mode and attempted to reset the path with:

mount -uw /         
ln -s /usr/local/bin/zsh /usr/bin/

then comming back and trying again without success.

I was directed to this channel in the comments at https://stackoverflow.com/q/70522270/2336356 where it is suggested I open a new terminal and make some changes:

You either changed your login shell to /usr/local/bin/zsh, or configured your default Terminal profile to start /usr/local/bi/zsh instead of your login shell. In either case, you can tell Terminal which process to run in a new terminal window.

However, any terminal I open, whether, iterm of kitty, for example, exit the process immediately after opening. This behavior started at the same time.

This has happened once before on an Intel Mac and I was able to fix it by logging into another admin user which had been set up in case something crazy like this happened. I cant seem to work it out this time.

Any guidance on a solution would be greatly appreciated.

Update

Here is a different error pointing to the same issue in the default terminal:

Last login: Wed Dec 29 19:09:59 on ttys001 login: /usr/local/bin/zsh: No such file or directory

[Process completed]

I then came across this issue https://apple.stackexchange.com/a/126303/174950 and switched to a different user and was able to cat /etc/shells as the affected user:

# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/fish
/usr/local/bin/pwsh
/usr/local/bin/zsh

I removed /usr/local/bin/zsh and now have:

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/fish
/usr/local/bin/pwsh

Still not working. Maybe I need to remove the ln -s /usr/local/bin/zsh /usr/bin/ symlink executed earlier?

2
  • Homebrew on a M1 is not in /usr/local - basically solution is remove all /usr/local entries for /etc/shells The read homebrew documents on where the path is. Also why use a zsh in /usr/local why not just use the Apple supplied one
    – mmmmmm
    Dec 29, 2021 at 19:06
  • 1
    You can temporarily select a different shell in the Terminal application's preferences. Not in a Terminal window -- that's not working, but under the Terminal menu > Preferences. See my answer to this question for details. Once you have it functioning, you can either use chsh to change it permanently (and remove the Terminal prefs override), or reinstall /usr/local/bin/zsh (and remove the Terminal prefs override). Dec 29, 2021 at 19:13

1 Answer 1

6

Homebrew installs programs under /usr/local on intel but under /opt/homebrew on arm. So once you've installed Homebrew's zsh, it will be at /opt/homebrew/bin/zsh. The zsh that ships with macOS is at /bin/zsh.

If you've hard-coded the path /usr/local/bin/zsh somewhere, you can use one of the following commands to make that exist:

sudo ln -s /bin/zsh /usr/local/bin
sudo ln -s /opt/homebrew/bin/zsh /usr/local/bin

Your attempt with ln didn't work because you passed the arguments to ln in the wrong order, and also because the preinstalled zsh is in /bin and not /usr/bin.

If you want to change your login shell, you can use the following command:

chsh -s /bin/zsh

Or chsh -s /opt/homebrew/bin/zsh to change to Homebrew's zsh.

Modern macOS comes with a recent version of zsh, so there's no advantage to using the one from Homebrew. It's not like bash where macOS ships only an ancient version.

1
  • I got my shell back with chsh -s /bin/zsh from the other user. Thank you for this very excellent answer. I should have asked 5 hours ago.
    – armand
    Dec 29, 2021 at 19:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .