zsh问题:compinit:503:没有那个文件或目录:/usr/local/share/zsh/site-functions/_brew

我正在使用苹果 M1 MacBook pro。

当我安装 oh my zash 时。当我添加export PATH="/opt/homebrew/bin:$PATH"到我的 ~/.zshrc 文件时。此错误显示在我的终端中:

joe :: share/zsh/site-functions » source ~/.zshrc
compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew
compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew_cask

但是,我检查并发现这两个文件确实存在。有人能告诉我问题出在哪里吗?

这是我的 ~/.zshrc 文件:

Last login: Sat Jan 16 14:53:34 on console
compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew
compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew_cask
[oh-my-zsh] Random theme 'jnrowe' loaded
? ~ ? cd ~
? ~ ? source .zshrc

compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew
compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew_cask
# export MANPATH="/usr/local/man:$MANPATH"
[oh-my-zsh] Random theme 'cypher' loaded
joe :: ~ » chmod 755 /usr/local/share/zsh
chmod 755 /usr/local/share/zsh/site-functions

joe :: ~ » sudo chmod 755 /usr/local/share/zsh
Password:
joe :: ~ » sudo chmod 755 /usr/local/share/zsh/site-functions
joe :: ~ » ls
#ZSH_DISABLE_COMPFIX=true

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

#Homebrew
export PATH="/opt/homebrew/bin:$PATH"
export PATH="/opt/homebrew/sbin:$PATH"
#Homebrew END

#Wget
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"
#Wget END

 #Path to your oh-my-zsh installation.
export ZSH="/Users/caizhuoyue/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="random"

"~/.zshrc" 114L, 3999C




回答

我有一个类似的问题。我跑了brew cleanup它修复了符号链接。

  • If you want to run a cleanup as a dry run, to see the intended effects first: `brew cleanup -n`

回答

一种更详细的方法是:

brew doctor
brew cleanup
source ~/.zshrc

或一行:

brew doctor && brew cleanup && source ~/.zshrc

在此之后,您可以查看使用 source 后是否出现任何错误。


回答

根据https://github.com/Homebrew/homebrew-core/issues/45009

尝试

sudo chown -R $(whoami):admin /usr/local/* && sudo chmod -R g+rwx /usr/local/*

然后

brew cleanup


回答

没错,解决此问题的最简单方法是运行: brew cleanup

只是,如果您同时保留 arm 和 x86 版本,请不要忘记使用 x86 brew 版本运行此命令。

这是我的一个非常低级的错误,在我终于意识到我需要使用 x86 brew 之前,我多次尝试使用默认的 brew 命令失败(我通过脚本安装它并且它已经链接到新的 arm 版本)执行cleanup命令。


回答

我有同样的这个问题,我在更新我的点文件时注意到了这个问题。

在 M1 上,我从 Intel brew 到 Intel 和 ARM brew,然后再到 ARM 版本。对我来说,问题是由两个指向英特尔版本的符号链接引起的,英特尔版本不再存在,而不是 ARM 版本。

我通过更改符号链接以指向 ARM 版本的正确位置来修复它。

ln -fsv /opt/homebrew/completions/zsh/_brew /usr/local/share/zsh/site-functions/_brew

ln -fsv /opt/homebrew/completions/zsh/_brew /usr/local/share/zsh/site-functions/_brew_cask

因此

lrwxr-xr-x    35 xxxx  2 Jun 16:02  _brew -> /opt/homebrew/completions/zsh/_brew
lrwxr-xr-x    35 xxxx  2 Jun 16:01  _brew_cask -> /opt/homebrew/completions/zsh/_brew

我认为 _brew_cask 指向同一个 _brew 是可以的,因为桶已经合并了。


以上是zsh问题:compinit:503:没有那个文件或目录:/usr/local/share/zsh/site-functions/_brew的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>