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.

Jeb Song
  • 51
  • 1
  • 4
  • 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 May 13 '22 at 07:39
  • 1
    If this fails, have you tried reinstalling homebrew? That seems to have fixed to the issue for some people. – Guchen May 13 '22 at 07: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 May 13 '22 at 08:30
  • @nohillside I'm on Intel, zsh is the default. Running on another account still shows the same errors. – Jeb Song May 13 '22 at 08: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 May 13 '22 at 09:30
  • Relevant from SO: https://stackoverflow.com/q/66119081/1256347 – Saaru Lindestøkke May 13 '22 at 11:15
  • @nohillside I downloaded the iterm2 shell configuration, but other than that I do not really remember what could have cause it. How should I go about fixing the /bin/bash problem? – Jeb Song May 14 '22 at 06:38
  • You might try to reinstall macOS. This should not delete your files but make to have a backup nevertheless. – nohillside May 14 '22 at 19:24
  • @nohillside Reinstalled, but there still seems to be no difference. – Jeb Song May 17 '22 at 02:11
  • Just to sure: Running /bn/bash leads to a killed error immediately? – nohillside May 17 '22 at 05:03
  • @nohillside Yes, and a few other ones like dstruss – Jeb Song May 18 '22 at 03:27

2 Answers2

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.

nohillside
  • 100,768
Jeb Song
  • 51
  • 1
  • 4
  • After removing yabai, did you actually re-enable SIP? – nohillside Jun 06 '22 at 09: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 Jun 08 '22 at 01: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.

bmike
  • 235,889
  • 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 May 14 '22 at 01: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 May 14 '22 at 01:47
  • Done that on another person's recommendation, still returned the exact same errors @bmike – Jeb Song May 14 '22 at 01:52
  • What shows in the console crash log at the time of the messages? – bmike May 14 '22 at 08: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 May 14 '22 at 14:43
  • You may need to reinstall your system if it’s not logging crashes for each of these kill events, then. https://stackoverflow.com/a/66637121/475228 or get someone who is skilled at this on your Mac to do the searching and fix – bmike May 14 '22 at 14:51