Asdf: Error when loading completions in zsh

Created on 2 Oct 2016  路  19Comments  路  Source: asdf-vm/asdf

complete:13: command not found: compdef

Most helpful comment

I was having the same problem with oh-my-zsh and the issue was that I was sourcing first the asdf completion ant then the oh-my-zsh.sh file, just changing the order like this solved the problem for me

```
source $ZSH/oh-my-zsh.sh
source $HOME/.asdf/asdf.sh
source $HOME/.asdf/completions/asdf.bash

All 19 comments

@devinus I'm using zsh with oh-my-zsh. Just loaded completions from latest master and works fine.
I found this issue upon Googling https://github.com/robbyrussell/oh-my-zsh/issues/3356. Looks like a general oh-my-zsh/zsh issue. Can you see if any of the solutions mentioned in the thread works for you and let us know?

I had the same problem a weeks ago. Moving autocompletion load code to .zshrc solved my issue.

Hope it helps :)

I'm having issues with the completions as well -- while I don't get any compdef error, I just don't see anything when doing

asdf <TAB>

@alexlafroscia I just realized the same thing happens to me. I will investigate and let you know tomorrow.

Actually, upon inspection my issue was due to . $HOME/.asdf/completions/asdf.bash not being present in my zshrc. Looking at the asdf README, the instructions say that's necessary. Are you sure you have that in your .zshrc? If it is you should be able to run which _asdf and see the completion function code.

which _asdf seems to work fine, but hitting <TAB> still doesn't do anything 鈽癸笍

@alexlafroscia that issue @HashNuke linked to suggests running rm ~/.zcomdump*. Did you try that?

I'm not sure why it's not working. Are your dotfiles up to date? I looked through them and didn't see anything that would cause this. You could try commenting out everything related to completion in your .zshrc and see if that changes anything.

I tried that command just now, that file does't exist apparently.

Dotfiles are up to date, yeah. I'll try to take some time to disable stuff and see if I can come across what's missing, but that sounds like a lengthy process so I'm not sure when that'll be.

I'm also getting the issue. I've tried removing ~/.zcomdump*, but they just generated again with every session.

Here is my latest file.

~/.zcompdump-5.2

@barberj is the _asdf function defined in your shell? which _asdf will tell you.

I do not. I commented also on the linked oh-my-zsh issue. It would appear more relevant there.

I was having the same problem with oh-my-zsh and the issue was that I was sourcing first the asdf completion ant then the oh-my-zsh.sh file, just changing the order like this solved the problem for me

```
source $ZSH/oh-my-zsh.sh
source $HOME/.asdf/asdf.sh
source $HOME/.asdf/completions/asdf.bash

I have a similar problem, using [[ $SHELL == *fish ]] && load_script "$HOME/.asdf/completions/asdf.fish" || load_script "$HOME/.asdf/completions/asdf.bash", which is sourced from .zshrc.

If I run the same command after .zshrc have run, then if works, but when starting a new shell it does not..

I have the same problem with asdf <TAB> doing nothing.
I have 0.4.0 version on Ubuntu.

The command which _asdf prints this:

_asdf () {
    local cur=${COMP_WORDS[COMP_CWORD]} 
    local cmd=${COMP_WORDS[1]} 
    local prev=${COMP_WORDS[COMP_CWORD-1]} 
    local plugins=$(asdf plugin-list | tr '\n' ' ') 
    COMPREPLY=() 
    case "$cmd" in
        (plugin-update) COMPREPLY=($(compgen -W "$plugins --all" -- $cur))  ;;
        (plugin-remove | current | list | list-all) COMPREPLY=($(compgen -W "$plugins" -- $cur))  ;;
        (install) if [[ "$plugins" = *"$prev"* ]]
            then
                local versions=$(asdf list-all $prev) 
                COMPREPLY=($(compgen -W "$versions" -- $cur)) 
            else
                COMPREPLY=($(compgen -W "$plugins" -- $cur)) 
            fi ;;
        (uninstall | where | reshim | local | global) if [[ "$plugins" = *"$prev"* ]]
            then
                local versions=$(asdf list $prev) 
                COMPREPLY=($(compgen -W "$versions" -- $cur)) 
            else
                COMPREPLY=($(compgen -W "$plugins" -- $cur)) 
            fi ;;
        (*) local cmds='plugin-add plugin-list plugin-remove plugin-update install uninstall update current where which list list-all local global reshim' 
            COMPREPLY=($(compgen -W "$cmds" -- $cur))  ;;
    esac
    return 0
}

and my .zshrc is this:

source $HOME/dotfiles/antigen.zsh

# Load the oh-my-zsh's library.
antigen use oh-my-zsh

# Bundles from the default repo (robbyrussell's oh-my-zsh).
antigen bundle git
antigen bundle heroku
antigen bundle fabiokiatkowski/exercism.plugin.zsh

# Load the theme.
antigen theme pygmalion

# Tell antigen that you're done.
antigen apply

source $HOME/.asdf/asdf.sh
source $HOME/.asdf/completions/asdf.bash

Someone has any idea?

Tnx

I think this issue may have been addressed in #266. Please upgrade to 0.4.2 follow the instructions in the readme for adding Zsh completion.

@alexlafroscia

which _asdf seems to work fine, but hitting <TAB> still doesn't do anything

@cLupus

If I run the same command after .zshrc have run, then if works, but when starting a new shell it does not.

I have the same problem. It only works if I source it manually in an active shell window.

Were you able to solve this?

Does it need a #compdef _cekit_completion cekit at the start ?

I use antigen for zsh and I solved the problem deleting ~/.antigen/.zcompdump

I have the same problem with asdf <TAB> doing nothing.
I have 0.4.0 version on Ubuntu.

The command which _asdf prints this:

_asdf () {
  local cur=${COMP_WORDS[COMP_CWORD]} 
  local cmd=${COMP_WORDS[1]} 
  local prev=${COMP_WORDS[COMP_CWORD-1]} 
  local plugins=$(asdf plugin-list | tr '\n' ' ') 
  COMPREPLY=() 
  case "$cmd" in
      (plugin-update) COMPREPLY=($(compgen -W "$plugins --all" -- $cur))  ;;
      (plugin-remove | current | list | list-all) COMPREPLY=($(compgen -W "$plugins" -- $cur))  ;;
      (install) if [[ "$plugins" = *"$prev"* ]]
          then
              local versions=$(asdf list-all $prev) 
              COMPREPLY=($(compgen -W "$versions" -- $cur)) 
          else
              COMPREPLY=($(compgen -W "$plugins" -- $cur)) 
          fi ;;
      (uninstall | where | reshim | local | global) if [[ "$plugins" = *"$prev"* ]]
          then
              local versions=$(asdf list $prev) 
              COMPREPLY=($(compgen -W "$versions" -- $cur)) 
          else
              COMPREPLY=($(compgen -W "$plugins" -- $cur)) 
          fi ;;
      (*) local cmds='plugin-add plugin-list plugin-remove plugin-update install uninstall update current where which list list-all local global reshim' 
          COMPREPLY=($(compgen -W "$cmds" -- $cur))  ;;
  esac
  return 0
}

and my .zshrc is this:

source $HOME/dotfiles/antigen.zsh

# Load the oh-my-zsh's library.
antigen use oh-my-zsh

# Bundles from the default repo (robbyrussell's oh-my-zsh).
antigen bundle git
antigen bundle heroku
antigen bundle fabiokiatkowski/exercism.plugin.zsh

# Load the theme.
antigen theme pygmalion

# Tell antigen that you're done.
antigen apply

source $HOME/.asdf/asdf.sh
source $HOME/.asdf/completions/asdf.bash

Someone has any idea?

Tnx

I solved it by sourcing asdf and asdf completion first before antigen.

source $HOME/.asdf/asdf.sh
source $HOME/.asdf/completions/asdf.bash

source $HOME/dotfiles/antigen.zsh

# Load the oh-my-zsh's library.
antigen use oh-my-zsh

# Bundles from the default repo (robbyrussell's oh-my-zsh).
antigen bundle git
antigen bundle heroku
antigen bundle fabiokiatkowski/exercism.plugin.zsh

# Load the theme.
antigen theme pygmalion

# Tell antigen that you're done.
antigen apply

Add the following to ~/.zshrc

for config_file ($HOME/.asdf/asdf.sh) source $config_file

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jayvdb picture jayvdb  路  4Comments

michalmuskala picture michalmuskala  路  5Comments

peleteiro picture peleteiro  路  3Comments

point-source picture point-source  路  4Comments

kevinkjt2000 picture kevinkjt2000  路  4Comments