Search my blog
Custom Search

2021/02/08

ZSH V5.6/oh-my-zsh compinit/compdef function definition not found

 Issue:

when run zsh, you got errors something like below:

compinit: function definition not found

compdef: function definition not found


Cause: 

Some Intel compiler will rewrite FPATH environment, FPATH doesn't include the correct function definition paths. 


Solution:

Newest version zsh's functions folder structure is changed from old versions. There are sub folders under /usr/share/zsh/functions folder and you have to add each sub folders in the FPATH as well. 

In your .zshrc, add the line below:

export FPATH="/usr/local/share/zsh/site-functions:/usr/share/zsh/vendor-functions:/usr/share/zsh/vendor-completions:/usr/share/zsh/functions/Calendar:/usr/share/zsh/functions/Chpwd:/usr/share/zsh/functions/Completion:/usr/share/zsh/functions/Completion/AIX:/usr/share/zsh/functions/Completion/BSD:/usr/share/zsh/functions/Completion/Base:/usr/share/zsh/functions/Completion/Cygwin:/usr/share/zsh/functions/Completion/Darwin:/usr/share/zsh/functions/Completion/Debian:/usr/share/zsh/functions/Completion/Linux:/usr/share/zsh/functions/Completion/Mandriva:/usr/share/zsh/functions/Completion/Redhat:/usr/share/zsh/functions/Completion/Solaris:/usr/share/zsh/functions/Completion/Unix:/usr/share/zsh/functions/Completion/X:/usr/share/zsh/functions/Completion/Zsh:/usr/share/zsh/functions/Completion/openSUSE:/usr/share/zsh/functions/Exceptions:/usr/share/zsh/functions/MIME:/usr/share/zsh/functions/Math:/usr/share/zsh/functions/Misc:/usr/share/zsh/functions/Newuser:/usr/share/zsh/functions/Prompts:/usr/share/zsh/functions/TCP:/usr/share/zsh/functions/VCS_Info:/usr/share/zsh/functions/VCS_Info/Backends:/usr/share/zsh/functions/Zftp:/usr/share/zsh/functions/Zle

:$FPATH"


NOTE:

If you /etc/zshrc is loading compinit, then you will need add this line at beginning of /etc/zshrc. 

If you don't have root access to /etc/zshrc, you may ignore errors and reload the items you need from .zshrc by yourself later (copy the /etc/zshrc configuration into your .zshrc file).