3

When I type brew, I get the output:

zsh: killed     brew

Writing out the whole path still gives the same output, so it doesn't seem like a path problem.

Furthermore, running /bin/bash gives the output:

zsh: killed     /bin/bash

I changed the names of .zshrc and .zprofile, yet the problem still persisted.

This also doesn't work on programs like pyenv. I also reinstalled xcode-select, yet the problem still persists. Furthermore, using the bash shell simply gives "process completed" (with deleted .bashrc and .bash_profile files).

I have both iterm2 and terminal, and running "/bin/zsh -x" on my mac terminal outputs stuff about iterm2, so I'm not sure what's happening there.

11
  • 1
    Are you on an Intel or an M1 Mac? Which zsh are you using, the default one or one you installed yourself? If you create a new user account on your Mac and try there, is the problem the same?
    – nohillside
    Commented May 13, 2022 at 7:39
  • 1
    If this fails, have you tried reinstalling homebrew? That seems to have fixed to the issue for some people.
    – Guchen
    Commented May 13, 2022 at 7:57
  • @Guchen I've tried, but my /bin/bash does not work at all, just returns "zsh killed /bin/bash", so when I do the installation zsh also kills the process.
    – Jeb Song
    Commented May 13, 2022 at 8:30
  • @nohillside I'm on Intel, zsh is the default. Running on another account still shows the same errors.
    – Jeb Song
    Commented May 13, 2022 at 8:30
  • 1
    Also, if running /bin/bash from /bin/zsh also ends up in killed then the problem doesn't directly seem related to Homebrew. Has it every worked correctly, can you remember any relevant change (software installation, crash) since then?
    – nohillside
    Commented May 13, 2022 at 9:30

2 Answers 2

2

I was able to solve this problem. I suspected that some login item made my /bin/bash turn weird. So under someone's recommendation I ran mac in safe mode, and found that everything ran perfectly. Thus, it was a specific login item which screwed up my bash.

For me, it was the yabai window management utility, as there must have been something in the startup script which screwed up my shell.

2
  • After removing yabai, did you actually re-enable SIP?
    – nohillside
    Commented Jun 6, 2022 at 9:51
  • Yes I re-enabled. I'm not sure if SIP is the culprit since I did safeboot and it worked, and I was able to disable SIP without any change to the terminal.
    – Jeb Song
    Commented Jun 8, 2022 at 1:33
1

The first two things I check is uptime and ps -ef | wc to make sure you don’t have runaway processes and the default limits. If the system is not healthy enough to run that, restart and if it still immediately kills the shell, start again but in safe mode.

https://support.apple.com/guide/mac-help/start-up-your-mac-in-safe-mode-mh21245/mac

Hopefully these triage steps let you know the Mac is configured and runs well after a start and you can watch for something that’s added that exhausts your process count.

Once you’re sure it’s not process count and repeatably just brew that crashes or gets killed, restart normally, and look in the console for what specifically is crashing.

Pay particular attention to the status of Rosetta 2 and which brew tools are installed for which processor architecture on your Mac.

softwareupdate --install-rosetta 

The output of brew doctor might be particularly helpful in this situation once obvious things are ruled out.

6
  • Thanks for the info. I'm trying to check the error messages on the Console, yet typing "bash" doesn't return anything, even when I type "/bin/bash" repeatedly (while returning zsh killed) in terminal. Is there any way to find the error report in this case?
    – Jeb Song
    Commented May 14, 2022 at 1:46
  • Any chance you can make a second account, log out the first - sign in as the second and see if that shell / account has issues @JebSong
    – bmike
    Commented May 14, 2022 at 1:47
  • Done that on another person's recommendation, still returned the exact same errors @bmike
    – Jeb Song
    Commented May 14, 2022 at 1:52
  • What shows in the console crash log at the time of the messages?
    – bmike
    Commented May 14, 2022 at 8:51
  • Nothing shows up, unable to find log on any terminal process (or I don't know the name). Used search terms "terminal", "zsh", and "kernel". First two did not return anything, last one return irrelevant reports.
    – Jeb Song
    Commented May 14, 2022 at 14:43

You must log in to answer this question.

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