5

When I use a terminal like iTerm or Hyper, right as I boot it up, the first message I get is:

complete:13: command not found: compdef

I don't know what this is from, and how to get rid of it. This message does not show up on the default terminal app though.

I am using zsh.

  • Can we assume your $SHELL is bash? – bmike Aug 27 '17 at 0:21
  • 1
    check your ~/.bashrc and ~/.bash_profile – Sairam Aug 27 '17 at 2:38
  • @Sairam Those should load up in the normal Terminal app though too. I'd take a look at this. – JMY1000 Aug 27 '17 at 7:11
  • I vote to close as the accepted answer could not be guessed n anyway from the question. ie no mention of zsh as shell. I do not see how this question helps other users. The answers cover many different things as the question is so poor. – Mark Oct 26 '18 at 10:44
  • 1
    @Mark I agree that the question could need some work. But zsh is actually mentioned, and anybody googling for the error message may learn something from the answer. – nohillside Oct 26 '18 at 11:10
5

After more research, I have found my answer. There was a block in my .zprofile:

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

The last line loads compdef. But when doing this it caused some sort of confliction. All I needed to do was comment out:

# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

And the annoying error went away. And the best part: I still have zsh tab completion.

5

This is the same issue I got on my mac OS. 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.

0

It depends on what you set as your default (login-)shell for the system, for Terminal, for iTerm. Updated bash installed and set to execute in one of them gives differing results.

This error comes from a so called dot-file you installed. These are files with a dot in front (hence the name) like .bashrc. That means they are invisible to the Finder and to a simple ls. The dot-files in question are read by your shell when it starts up. They contain instructions, settings, customisations; maybe little snippets of program code.

Not all dot-files in your users home directory are read by the shell. Those read by bash may include: .bash_history .bash_profile .bash_prompt .bash_sessions .bashrc .editorconfig .exports .functions .inputrc .profile (This list is not exhaustive)

Those files may have been created by you, manipulated by you or by certain programs like fink, homebrew or ports. You may have just copied those from the net to "upgrade"/personalize your shell.

Regardless of how you arrived at the current situation. Open your Terminal/iTerm from another user and the symptoms will probably not be observed.

That means: all those files are in a sense 'safe to delete': in the sense that they are not essential for running your Terminal or your shell. Make a backup of those in case they indeed contain personalised settings you may depend on in your daily work. Examples for that include additions to your $PATH variables. Without those you may find programs like fink no longer working.

However the actual error message you posted indicates two things:

  • The combined content of your dot-files did not work to accomplish what they were supposed to do. More exact: an instruction (compdef) was called and that is not available.

  • That you very probably sourced a bunch of dot-files from a source on the net like holman-dotfiles. These included a bug that had the exact same error message.

So you should look through all of the dot-files for your current user and keep only the stuff you recognise as necessary (remember the backups). Then you might use the updated files from your source again. But keep in mind that these are quite 'comprehensive'. It would be prudent to not use them all blindly and actually test and pick a subset of all those options.

Using them all blindly or indiscriminately may not only lead to issues like the one prompting this question but also when following other how-tos or troubleshooting advice.

Update: This answer was given to a previous version of the question that did not indicate zsh as the shell used. -> Substitute zsh where you read bash above.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .