解决oh-my-zsh的Command not found: compdef错误

不知怎么回事,突然就出现了这样的错误:

/home/deloz/.oh-my-zsh/lib/directories.zsh:32: command not found: compdef
[oh-my-zsh] plugin 'curl' not found
[oh-my-zsh] plugin 'wget' not found
[oh-my-zsh] plugin 'php' not found
[oh-my-zsh] plugin 'vim' not found

或 执行 ~/.zshrc时出现错误:

➜  ~ . ~/.zshrc 
[oh-my-zsh] plugin 'curl' not found
[oh-my-zsh] plugin 'wget' not found
[oh-my-zsh] plugin 'php' not found
[oh-my-zsh] plugin 'vim' not found

尝试删除rm ~/.zcompdump*,无果。

尝试upgrade_oh_my_zsh升级,也无果。

查看GitHub上最近issue的https://github.com/robbyrussell/oh-my-zsh/issues/7846 讨论,跟踪到https://github.com/robbyrussell/oh-my-zsh/issues/7171

以下代码必须放在 source $ZSH/oh-my-zsh.sh之后。

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

可是,我本机并未安装nvm

尝试从plugins=(curl wget php vim) 中删除不要的插件。

最后,重装了结。

重装ohmyzsh

rm -rf ~/.oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)
Leave a Reply