Closed maciejp-ro closed 3 years ago
For the record, the following snippet on top of ~/.zshrc
helps (by checking executable path and exiting early if it's /bin/zsh
):
if [[ "$(lsof -p $$ | awk '$4 == "txt" && /\/zsh$/ { print $9 }')" == '/bin/zsh' ]]; then
return
fi
If the fix involves using Homebrew's zsh, please indicate a way to detect in ~/.zshrc
that the shell is executed from homebrew and/or implement a way to prevent Homebrew from trying to run my shell.
How do you suggest that we query FPATH
?
My approach would be not to query it at all because we can't predict what user has in their config (including a completely broken config because they don't run zsh and don't care). Just display a message that they might need to add site-functions
directory to fpath
. Then I'd make it possible to turn this message off when user already read and applied it (or knows they won't need it because they don't use zsh), something like "to never see this message again, run brew dismiss zsh-completion-caveat
", which would be universally helpful for all kinds of messages.
If we try to check, it should be safeguarded with timeouts, exit status checks (which also don't seem to be there because homebrew didn't mind when I just killed the hanging zsh), stdin redirected from /dev/null
to break most attempts at reading input from user (they still might hang in a retry loop if badly written, but it should catch most interaction attempts) and written with defensive programming matching the awareness that we literally execute arbitrary shell that might go wrong in all sorts of ways. Writing it defensively enough to be robust feels beyond my skill level – which is why my first instinct would be to find a way to avoid writing it at all.
I second this. Experienced this very issue today. This broke my upgrade path out of the blue. I'm glad that @maciejp-ro caught this so early.
I don't see an obvious reason why CI tests were skipped for https://github.com/Homebrew/brew/pull/9404
I don't see an obvious reason why CI tests were skipped for #9404
@jottr They weren't.
My bad! Thanks for the quick fix.
@jottr No worries, thanks for the kind words!
Bug report
Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.
brew update
and can still reproduce the problem?brew doctor
, fixed all issues and can still reproduce the problem?brew config
andbrew doctor
and included their output with your issue?What you were trying to do (and why)
I was trying to run
brew upgrade
, as i do daily, to upgrade installed softwareWhat happened (include command output)
It hanged. Multiple times.
Command output
This is the point when it hanged. I looked at `pstree` what it was doing: Killing `/bin/zsh` made it continue and emit a caveat: This repeated for every package that was installing ZSH completion functions.What you expected to happen
I expected brew to run and upgrade my packages. I would be happy with an unnecessary notice about
site-functions
, or with no notice at all (even if it would be necessary), or with being able to turn the extra helpfulness off.I expected brew not to run an "interactive" shell when it's not interactive, in a wrong version. Homebrew was started from a zsh session, in zsh that brew itself installed, first on
$PATH
, and with$SHELL
set to/usr/local/bin/zsh
. Homebrew really went out of its way to pick the wrong zsh.I don't know if finding correct zsh would help. My
.zshrc
is complex, and interactive shells are supposed to be interactive. Maybe there would be a workaround, but it won't ever be universal, because I am allowed to putsleep 3600
in my.zshrc
for no reason and it shouldn't break Homebrew.Step-by-step reproduction instructions (by running
brew
commands)~/.zshrc
brew upgrade
orbrew install
of a package that has ZSH completionzsh -i
non-interactively using wrong zsh and get confused if zsh tries to be interactiveOutput of
brew config
andbrew doctor
commands