asdf: $HOME/.asdf/completions/asdf.bash:68: command not found: complete

Steps to reproduce

  1. Use zsh
  2. Install asdf
  3. Install completions according to documentation

Expected behavior

No errors happen

Actual behavior

I’m getting:

/home/quintasan/.asdf/completions/asdf.bash:68: command not found: complete

on every terminal launch

Environment

OS: Ubuntu 18.04

asdf version: v0.7.8-4a3e3d6

zsh version: zsh 5.4.2 (x86_64-ubuntu-linux-gnu)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 20
  • Comments: 24 (11 by maintainers)

Most upvoted comments

Adding this fixed it for me: autoload -U +X bashcompinit && bashcompinit

@teodorlu Thanks for the further information. It seems from your zcompdump doesn’t have an asdf entry which indicates that you’re not running compinit after sourcing asdf or it’s completions. I will update the docs with code samples for the common variations, but essentially you want to:

# source asdf
. $HOME/.asdf/asdf.sh
# add asdf completions to fpath
fpath=(${ASDF_DIR}/completions $fpath)
# run compinit
autoload -Uz compinit && compinit

version 0.7.6 didn’t require the last two steps as the bash completions and call to compinit were run automatically by the $HOME/.asdf/asdf.sh script.

🎺 🎺 🎺 The asdf core team are not the authors of most (if any) of these shell plugins, so we are relying on people from the community to help update these plugins for a better ZSH user experience. If you’re familiar with any plugins and have the time to help, it would be much appreciated.

I would advise anyone looking to help to read https://github.com/ohmyzsh/ohmyzsh/issues/8779 as the fpath/compinit lifecycle of the tool the plugin is for is important for the implementation.

Thanks for your patience while we work towards a better ZSH experience for all asdf users.

I have had luck putting this in my .zprofile:

# Turn on ZSH autocomplete
# https://unix.stackexchange.com/a/477909

autoload -Uz compinit && compinit

# Setup Homebrew in PATH =>
eval "$(/opt/homebrew/bin/brew shellenv)"

# Setup asdf
# https://hackercodex.com/guide/python-development-environment-on-mac-osx/

. $(brew --prefix asdf)/asdf.sh
asdf reshim python
asdf reshim nodejs

# https://github.com/asdf-vm/asdf/issues/692#issuecomment-642748733
autoload -U +X bashcompinit && bashcompinit

# set up bash completions
# https://blog.natterstefan.me/how-to-use-multiple-node-version-with-asdf
. $(brew --prefix asdf)/etc/bash_completion.d/asdf.bash

For some reason I don’t understand the compinit and bashcompinit lines seem to both be necessary.

Reverting to v0.7.6 with

git checkout v0.7.6

in the asdf install folder, I am no longer seeing any errors on startup.

Chiming in with my experience in case it helps someone track this down:

Works for me

asdf version: v0.7.6-6207e42

My current dotfiles - see ./zsh/zshrc.symlink

  • Source . $HOME/.asdf/asdf.sh after path setup (system/_path.zsh)
    • I think I accidentally have this duplicated in asdf/asdf.zsh - I moved it into _path because I wanted asdf shims to take precedence over brew versions
  • Source . $HOME/.asdf/completions/asdf.bash after compinit (asdf/completion.zsh)
    • This might also be getting sourced twice by accident - will need to look into that as well.

$ asdf l<tab> autocompletes to list, list-all, and local as expected.

Note: I am not sure that these settings are remotely correct, but they are working.

Upgrade steps

  1. asdf update (brings me to v0.7.8-4a3e3d6)
  2. Remove all existing asdf configuration I am aware of from my .zshrc / etc
  3. Follow the asdf docs for ZSH to add new configuration values

$ asdf l<tab> produces the following:

~ ➜ asdf l(eval):1: command not found: _bash_complete
asdf

If I source the previous completions/asdf.bash file from above, I get the error that OP experienced, so I think we’re running into the same thing overall.

Here’s a branch of my dotfiles with the new configuration. I also tried installing bash-completion via homebrew and following the post-install instructions to source that, but it doesn’t seem to help.

If I cd into ASDF_DIR, check out 6207e42 (0.7.6), and revert my dotfiles, everything works again. It seems like the issue started occurring for me in 0.7.7 and continues into 0.7.8.

Notes:

  • I have not tried the homebrew instructions yet, but am planning to do that next.
  • Other completions for git / etc continue to work - this is limited to asdf

Environment

OS: MacOS Mojave 10.14.6

zsh version: zsh 5.7.1 (x86_64-apple-darwin17.7.0)

zsh-related homebrew libraries

  • zplug
  • zsh
  • zsh-completions

zplug plugins

  • shipstar/hyperzsh (just prompt styling)
  • zsh-users/zsh-syntax-highlighting

Note that I am not using a zsh manager like oh-my-zsh that could be conflicting.

@shipstar I was unable to reproduce your issue of

'asdf' '_bash_complete -F _asdf'

on a fresh install of macOS. Let me know if the state of your env changes. There’s perhaps more variables of your env we need to dig into to solve this.

Given the OP has had their issue resolved and the docs have been updated to prevent their particular case, I am going to close this issue.

@shipstar please don’t hesitate to open a new issue and assign it to me if your problem persists. We can continue debugging your setup there 👍

@jthegedus since I’m a lazy bum I’m going to wait for https://github.com/ohmyzsh/ohmyzsh/pull/8837 to be merged and report back if it fixes the problem 😉

EDIT: I couldn’t wait after all - it works!