ohmyzsh: compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew
I am using Apple M1.
When I added this line:
export PATH="/opt/homebrew/bin:$PATH"
to ~/.zshrc file.
These error messages came up:
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
I dont know that’s the problem and how to fix this.
I went to the directory /usr/local/share/zsh/site-functions and these two files do exist.
Also, I used chmod 755 /usr/local/share/zsh/site-functions/_brew and chmod 755 /usr/local/share/zsh/site-functions/_brew_chask
My ~/.zshrc file:
#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
Problem solved.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 18 (4 by maintainers)
Per https://github.com/ohmyzsh/ohmyzsh/issues/9602#issuecomment-768532307,
brew cleanupfixed it for me.(And you can do a “dry run” with
brew cleanup -nto see what would happen during the cleanup without actually executing it.)I had to run
brew install brew-cask-completion, which solved the issue.This is not specific to M1 chip. But
brew cleanupseems to have fixed the issueThis is a Homebrew problem. See here and the fix
Try
rm ~/.zcompdump*and thenexec zsh.Thanks again for your promp reply! This is what I got from using
ls -l /usr/local/share/zsh/site-functions/_brew*:So,these are symlinks. And they point to
usr/local/Homebrew/completions/zsh/_brew_cask. However, for M1 homebrew is under/opt/homebrew. I guess that’s the problem.Any idea how to fix it? Make the symlinks point to the files under
/opt/homebrew? Would that work?Oh, actually, it’s two aliases. I made new ones pointing to
/opt/homebrew/completions/zsh/_brewand/opt/homebrew/completions/zsh/_brew_cask. Then I deleted the old aliases.When I used
source ~/.zshrc, no more error messages!Problem solved! Thank you so much 😃
I had this issue too. Tried running
brew cleanupandbrew cleanup -nas recommended by @jsejcksn but still had the same issue.Ended up just deleting the broken alias (
rm /usr/local/share/zsh/site-functions/_brew_cask) and runningbrew doctor/brew cleanupagain and it seemed to fix it after a quick reload.brew doctor brew cleanup source .zshrc
Great! You might want to make an issue on the Homebrew project or post a new discussion in https://github.com/Homebrew/discussions to get more specific support as to why this is like this. It might be a bug or something.
PS. Also it’s better to use
exec zshto reload the zsh session,source ~/.zshrccould have side effects.The
PATHdirectory should use forward slashes:export PATH="/opt/homebrew/bin:$PATH". If that doesn’t solve it, which it probably won’t, tryrm $ZSH_COMPDUMPand restart zsh withexec zsh.