Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Quintasan opened this issue Apr 6, 2020 · 24 comments
Closed

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

Quintasan opened this issue Apr 6, 2020 · 24 comments
Assignees

Comments

@Quintasan
Copy link

Quintasan commented Apr 6, 2020

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)

@jthegedus
Copy link
Contributor

Interesting. completions/asdf.bash should not be executed by any ZSH setup. Which specific setup have you followed for asdf completions as the documentation point to a number of ways to setup ZSH completions but none direct you to using the asdf.bash script itself.

@jthegedus jthegedus self-assigned this Apr 7, 2020
@goetzc
Copy link

goetzc commented Apr 7, 2020

@jthegedus
Copy link
Contributor

jthegedus commented Apr 7, 2020

Ah, yes, a number of the asdf plugins will source this as the ZSH completions are new and those plugins have not been updated. I have opened a discussion around how to correctly implement the new completions with the oh-my-zsh asdf plugin ohmyzsh/ohmyzsh#8779

As with the command not found: complete error, complete has been a requirement for the bash completions and these plugins for a few years, so you will need to install bash-completion if it is missing from your system.

@jthegedus
Copy link
Contributor

jthegedus commented Apr 7, 2020

🎺 🎺 🎺
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 ohmyzsh/ohmyzsh#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.

@shipstar
Copy link

shipstar commented Apr 14, 2020

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
Copy link

One more angle: I just tried deleting ~/.asdf and reinstalling asdf via Homebrew. I'm still getting the same completion error above on 0.7.8. As far as I can tell, the only asdf-related config I have in my dotfiles is now . $(brew --prefix asdf)/asdf.sh at the end of my .zshrc.

Updated dotfiles

@jthegedus
Copy link
Contributor

@shipstar Thanks for reporting.

I would recommend only testing with 0.7.6 and 0.7.8 as 0.7.7 performed some compinit commands automatically which was ultimately determined to be detrimental.

As with your specific error of asdf l(eval):1: command not found: _bash_complete, the complete command is never used in the ZSH completions and has always appeared in the Bash completions, so I would think that there are some latent config values somewhere in your shell.

It seems like the issue started occurring for me in 0.7.7 and continues into 0.7.8.

I would also suggest looking for and deleting any ~/.zcompdump* as mentioned above 0.7.7 ran compinit which may affect the rest of your setup.

@shipstar
Copy link

shipstar commented Apr 15, 2020

Thanks for the update on 0.7.7 - will skip that version.

I did have a ~/.zcompdump file, which I removed, but I'm still seeing the same issue in a fresh terminal.

Assuming I do have some latent bash config values hanging around, any ideas why zsh autocompletion is working for other tools but not asdf? Seems odd that nothing else would be throwing the same error.

I'll keep digging and report back if I figure it out!


EDIT: I know dotfiles can be a tangled mess, so not expecting specific help with my situation. Just trying to understand the variables in play here, e.g. .zcompdump was helpful to know about.

@shipstar
Copy link

Possible progress - when I run compinit from a prompt (or as part of my .zshrc) after deleting the .zcompdump file, it generates a new .zcompdump file as expected. Here's the asdf entry from that file:

'asdf' '_bash_complete -F _asdf'

If I change that line in .zcompdump to 'asdf' '_asdf', autocomplete works as expected on 0.7.8.

I'm not sure what's placing the incorrect entry into .zcompdump, though. I do have https://github.com/zsh-users/zsh-completions installed via Homebrew to provide some additional autocompletion options, but I don't see an asdf entry in there that might be conflicting. I also made sure to update that to latest (0.31.0), although it seems to be about 6 months old.

I'll edit my .zcompdump as a workaround for now, but hopefully this helps.

@teodorlu
Copy link

teodorlu commented Apr 16, 2020

I am also seeing this error.

In my dotfile, I have

$ cat .zshrc.local | grep asdf
source $HOME/.install/asdf/asdf.sh
# source $HOME/.install/asdf/completions/asdf.bash

, and on terminal startup, I am seeing

/home/teodorlu/.install/asdf/completions/asdf.bash:68: command not found: complete
  • I am experiencing the same issue as @Quintasan and @shipstar
  • I did not have any issues on 0.7.6
  • I am seeing issues on 0.7.8

My ZSH config is quite close to a vanilla grml-zsh-config, so not too much weird stuff going on.

I'd also like to use this chance to say thank you for a great, simple version manager! When I was able to replace nvm + similar things for other languages with asdf, my shell startup went from annoying to instant. Thanks!

@teodorlu
Copy link

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.

@jthegedus
Copy link
Contributor

jthegedus commented Apr 16, 2020

@shipstar That is an interesting find, thanks. Perhaps the way the Brew installation is setting the completions is incorrect. I will test on a macOS machine.

@teodorlu a few questions:

  • Did you install via Brew?
  • When reverting, are you also adding $HOME/.install/asdf/completions/asdf.bash back into the mix?
  • are you able to share your .zcompdump contents for asdf as @shipstar did above?

I think the main issue here is the changes to the asdf.sh file between the versions 0.7.6 and 0.7.8. v0.7.6...v0.7.8

asdf.sh v0.7.6 performs bashcompinit if your shell is detected to be ZSH, so in your new v0.7.8 setup you should need to run compinit after adding to your fpath and sourcing asdf in your .zshrc. I believe this is the source of some problems, and by extension the issue @shipstar found with .zcompdump asdf entry.

The docs are very confusing atm for ZSH users (to much information on screen) and the migration path from 0.7.6 to 0.7.8 isn't documented which might be worth also adding to the docs (I am working on an update atm).

Your reports are appreciated. Keep the info coming.

@teodorlu
Copy link

teodorlu commented Apr 16, 2020

Did you install via Brew?

Nope, I'm on Linux. Ubuntu 18.04. I think I cloned directly into ~/.install/asdf and added the following into my ZSH rc file manually:

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

When reverting, are you also adding $HOME/.install/asdf/completions/asdf.bash back into the mix?

I did not add the completions script back into the mix. I can try re-adding them and see what happens.

are you able to share your .zcompdump contents for asdf as @shipstar did above?

Attached: zcompdump.txt. Crossing my fingers that no private stuff has snuck in there ...

@teodorlu
Copy link

Still on 0.7.6, I added source $HOME/.install/asdf/completions/asdf.bash back into my ZSH RC file, and completions seem to be working:

image

@jthegedus
Copy link
Contributor

jthegedus commented Apr 17, 2020

@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.

@jthegedus
Copy link
Contributor

New docs are out which should make it easier to see the config required for your specific OS/Shell/Install Method combination.

@jthegedus
Copy link
Contributor

So @Quintasan @goetzc @shipstar @teodorlu was the information in this thread enough for you to each resolve your problems?

@Quintasan
Copy link
Author

Quintasan commented Apr 23, 2020

@jthegedus since I'm a lazy bum I'm going to wait for ohmyzsh/ohmyzsh#8837 to be merged and report back if it fixes the problem ;)

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

@shipstar
Copy link

shipstar commented Apr 26, 2020

I still have the same issue in my .zcompdump file using MacOS 10.14.6 + Homebrew 2.2.13 + asdf v0.7.8. My current workaround is still:

  1. rm ~/.zcompdump
  2. Reload terminal, which executes these lines from my .zshrc file:
    # from Homebrew instructions linked from asdf docs:
    # https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh
    if type brew &>/dev/null; then
      FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
    
      autoload -Uz compinit
      compinit
    fi
    
    # the very last line
    . $(brew --prefix asdf)/asdf.sh
    
  3. Edit ~/.zcompdump to replace the bad asdf line per my comment above

The completions in .zcompdump don't seem to be overridden with any regularity, so this workaround has been OK for me. I only need to go through these steps if I rm ~/.zcompdump.

I'm planning to move to a new computer in the next few weeks, so I'll test from a fresh install and try to report back then.


Despite my minor issues, I just wanted to say that the new docs are much easier to follow. 💯Thanks for making time to improve those!

@jthegedus
Copy link
Contributor

I will see if I can replicate on my macOS device, thanks @shipstar

@jthegedus
Copy link
Contributor

jthegedus commented May 14, 2020

@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 👍

@cocoonkid
Copy link

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

@jthegedus
Copy link
Contributor

@cocoonkid It sounds like you're using the Bash completions. If your Shell is ZSH we have native ZSH completions which the documentation site will help you setup 😄 https://asdf-vm.com/#/core-manage-asdf-vm

@jlumbroso
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants