Asdf: complete:13: command not found: compdef

Created on 27 Dec 2017  路  3Comments  路  Source: asdf-vm/asdf

Steps to reproduce

Follow the installation instructions in the readme

Expected behavior

exec zsh does not exit with a non-zero status code.

Actual behavior

exec zsh exits with a non-zero status code and displays the message:

complete:13: command not found: compdef

Environment

> zsh --version
zsh 5.4.2 (x86_64-apple-darwin17.0.0)
> which zsh
/usr/local/bin/zsh

(this is my homebrew installed version of zsh)

OS: OS X 10.13.2

asdf version: 0.4.1

Every time I open a new iTerm2 window or spawn a new tmux window/pane, I see the complete:13: command not found: compdef error, which is caused by zsh running my .zshrc which contains . $HOME/.asdf/completions/asdf.bash, which runs the last line of that file, which is complete -F _asdf asdf.

If I just run complete, I see the same error (complete:13: command not found: compdef).

If I just run compdef, I see zsh: command not found: compdef

There are several google search results for issues related to oh-my-zsh, which I am not using.

Solution

This page details how to get to a solution.

Basically, I had to have some lines above the asdf config lines in my .zshrc:

autoload -Uz compinit
compinit

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

If a github issue is not the correct way to document this, I'm sorry. This took me about an hour to figure out and I figured it'd be nice to have here for posterity.

Most helpful comment

Thanks for taking the time to document this in an issue. It's very helpful. I guess now we need to figure out how to address this. If it's something that's going to be experienced by all users (or at least those on the same versions) we should probably add this information to the readme.

All 3 comments

Thanks for taking the time to document this in an issue. It's very helpful. I guess now we need to figure out how to address this. If it's something that's going to be experienced by all users (or at least those on the same versions) we should probably add this information to the readme.

If it helps at all, I started 2 days ago with a new re-image of high sierra to start building my own set of dotfiles. There aren't a lot right now. ./install.sh has everything I've done on the re-imaged machine up to this point. Maybe there's a confounding variable in there which caused this. I don't think so, but I'm wrong lots.

I think it is unlikely to be a confounding variable @pachun. I can reproduce the same errors on Fedora 27 with some configurations of my .zshrc. Here's what I've found:
OMZSH, (among many, many other things) runs the command

 autoload -U compaudit compinit

Since you aren't using OMZ, or another framework that does this as part of its init, you have to take care of it manually. It's the same for me when not running a framework.

@Stratus3D I think we could update the readme to emphasize that if you are not using a framework for zsh, you need to do this yourself. Also, if you are using a framework, you need to source it before the asdf lines. Following the instructions blindly will append them, but it's better to be explicit so folks can figure out why changing that order will break things. I'll submit a PR with an updated readme, feel free to use it if it's useful.

I'm just testing out asdf but so far it looks pretty great. Thanks for all your hard work!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ypid picture ypid  路  3Comments

jayvdb picture jayvdb  路  4Comments

rhiroyuki picture rhiroyuki  路  3Comments

gmile picture gmile  路  3Comments

peleteiro picture peleteiro  路  3Comments