每个brew命令都挂起而没有输出

问题描述 投票:0回答:1

由于挂起几分钟而在中间终止一些brew命令后,我运行的每个brew命令都挂起而没有输出,包括推荐的故障排除命令,如

brew config
brew doctor
brew update -d
brew irb
等。我验证了 homebrew-core git 存储库是干净且最新的。我尝试在一些 github 问题提到的
.git
中创建临时目录。

macos homebrew
1个回答
0
投票

对我来说,解决方案似乎是重新启动机器,但我做了一些有趣的调试,可能会帮助您解决不同的问题:

事实证明,brew 是一堆 shell 脚本,所以我可以使用

bash -x
运行它们并查看它到底挂在哪里。对我来说,挂起发生在 git shim 中,并在之后修复了

$ which brew
/opt/homebrew/bin/brew
$ bash -x /opt/homebrew/bin/brew
[...]
+ exec /usr/bin/env -i HOME=/Users/aursaraf SHELL=/bin/zsh PATH=/usr/bin:/bin:/usr/sbin:/sbin TERM=xterm-256color LOGNAME=aursaraf USER=aursaraf SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.zWuAbnMT5N/Listeners HOMEBREW_BREW_FILE=/opt/homebrew/bin/brew HOMEBREW_CELLAR=/opt/homebrew/Cellar 'HOMEBREW_EDITOR=code-insiders -w' HOMEBREW_LIBRARY=/opt/homebrew/Library HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_PATH=/opt/homebrew/Caskroom/miniforge/base/condabin:/Users/aursaraf/.nvm/versions/node/v16.16.0/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/aursaraf/.cargo/bin HOMEBREW_PREFIX=/opt/homebrew HOMEBREW_REPOSITORY=/opt/homebrew HOMEBREW_USER_CONFIG_HOME=/Users/aursaraf/.homebrew /bin/bash -p /opt/homebrew/Library/Homebrew/brew.sh update
# run that line with an added -x
$ exec /usr/bin/env -i HOME=/Users/aursaraf SHELL=/bin/zsh PATH=/usr/bin:/bin:/usr/sbin:/sbin TERM=xterm-256color LOGNAME=aursaraf USER=aursaraf SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.zWuAbnMT5N/Listeners HOMEBREW_BREW_FILE=/opt/homebrew/bin/brew HOMEBREW_CELLAR=/opt/homebrew/Cellar 'HOMEBREW_EDITOR=code-insiders -w' HOMEBREW_LIBRARY=/opt/homebrew/Library HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_PATH=/opt/homebrew/Caskroom/miniforge/base/condabin:/Users/aursaraf/.nvm/versions/node/v16.16.0/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/aursaraf/.cargo/bin HOMEBREW_PREFIX=/opt/homebrew HOMEBREW_REPOSITORY=/opt/homebrew HOMEBREW_USER_CONFIG_HOME=/Users/aursaraf/.homebrew /bin/bash -x -p /opt/homebrew/Library/Homebrew/brew.sh update
[..]
++ git -C /opt/homebrew rev-parse HEAD

此时我尝试手动运行这个 git 命令并且它起作用了,所以我再次运行了brew 命令并在一个单独的 shell 中运行了

ps -aux | grep git

并发现实际上它并不是真正的

git
,而是
/opt/homebrew/Library/Homebrew/shims/shared/git
,这对我自己来说有点难运行(它一直抱怨只有
brew.sh
应该运行它)但是如果我在最后一个命令是
/opt/homebrew/Library/Homebrew/brew.sh
我可以看到它运行。
...然后我想到我应该尝试重新启动,问题就消失了。

© www.soinside.com 2019 - 2024. All rights reserved.