zsh: command not found: {compinstall,compinit,compdef}

This is the same issue I got on my mac. I am using zsh shell.

Zsh Compdef error

Compdef is basically a function used by zsh for load the auto-completions. The completion system needs to be activated. If you’re using something like oh-my-zsh then this is already taken care of, otherwise you’ll need to add the following to your ~/.zshrc

autoload -Uz compinit
compinit

Completion functions can be registered manually by using the compdef function directly like this compdef . But compinit need to be autoloaded in context before using compdef.


Answer to the question as asked

Access these commands by running:

$ autoload -Uz compinstall && compinstall

It will load a guided wizard, I quit as soon as I had the option to Save and exit.

Then reload the shell:

$ exec zsh

More general answer

It appears that the new user configuration was not run.

Run it by:

$ autoload -Uz zsh-newuser-install && zsh-newuser-install -f