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

complete:13: command not found: compdef #1707

Closed
revolter opened this issue Jan 13, 2018 · 14 comments
Closed

complete:13: command not found: compdef #1707

revolter opened this issue Jan 13, 2018 · 14 comments
Labels
pull request wanted This is a great way to contribute! Help us out :-D shell: zsh

Comments

@revolter
Copy link

  • Operating system and version

macOS 10.13.2 (17C88)

  • nvm debug output:
nvm --version: v0.33.4
$TERM_PROGRAM: iTerm.app
$SHELL: /bin/zsh
$HOME: /Users/revolt
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.3 (x86_64-apple-darwin17.0)'
uname -a: 'Darwin 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64 x86_64'
OS version: Mac 10.13.2 17C88
curl: /usr/bin/curl, curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
wget: /usr/local/bin/wget, GNU Wget 1.19.2 built on darwin17.3.0.
git: /usr/local/bin/git, git version 2.15.1
nvm current: v8.9.4
which node: $NVM_DIR/versions/node/v8.9.4/bin/node
which iojs: iojs not found
which npm: $NVM_DIR/versions/node/v8.9.4/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v8.9.4
npm root -g: $NVM_DIR/versions/node/v8.9.4/lib/node_modules
  • nvm ls output:
->       v8.9.4
         system
default -> lts/* (-> v8.9.4)
node -> stable (-> v8.9.4) (default)
stable -> 8.9 (-> v8.9.4) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.9.4)
lts/argon -> v4.8.7 (-> N/A)
lts/boron -> v6.12.3 (-> N/A)
lts/carbon -> v8.9.4
  • How did you install nvm? (e.g. install script in readme, homebrew):

It was installed by Realm using:

curl -s https://raw.githubusercontent.com/realm/realm-object-server/master/install.sh | bash
  • What steps did you perform?

After nvm installed, I ran:

exec zsh -l && . ~/.zshrc
  • What happened?

The following error was printed out:

complete:13: command not found: compdef
  • What did you expect to happen?

Not throw an error.

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?

Yes, but it's not related.

The line that's causing this is:

https://github.com/creationix/nvm/blob/d34bb3247d689e926a36c3b6e26a3378b780a982/bash_completion#L97

It might be solved by using compctl -K __nvm nvm instead, maybe with an approach similar to fastlane's, though I'm not sure.

@ljharb
Copy link
Member

ljharb commented Jan 13, 2018

I'm not familiar with realm. The proper (and only supported) install method is in the readme, namely, installing from this git repo. Does the same thing happen if you install it that way?

It seems like the error is occurring inside complete itself. What does type complete print out?

@revolter
Copy link
Author

I'm not sure how to reinstall it but I'm pretty sure it won't fix it, as using complete is not the correct way to configure autocomplete under zsh.

type complete prints complete is a shell function from /Users/revolt/.nvm/bash_completion.

Realm installs nvm by running:

nvm_url="https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh"
curl -s -o- "${nvm_url}" | bash

So the only differences are that it installs using the -s flag which downloads it silently and that it installs the version 0.33.4 instead of 0.33.8, but the bash_completion file from master still uses the complete command.

@ljharb
Copy link
Member

ljharb commented Jan 14, 2018

Gotcha. It is a “bash completion” file, so it makes sense that it might not work on zsh - however, it seems to work in local testing.

Is there anything about your install of zsh that might change this?

@revolter
Copy link
Author

So that error isn't printed for you when you reload the .zshr file?

Is there anything about your install of zsh that might change this?

I don't know, it's hard to figure out if and what might cause this.

I do have autoload -U compinit; compinit in my .zshr file but it looks like this is used to replace compctl, not enable/force it.

@ljharb
Copy link
Member

ljharb commented Jan 14, 2018

ah, i could have sworn i had bash_completion in my zshrc file, but i didn't.

When i run . .nvm/bash_completion in my quite stock zsh, I get complete:13: command not found: compdef as well.

Running compctl -K __nvm nvm instead doesn't add tab-completion to my zsh session, however.

I'm certainly open to modifying this file so it can work in zsh, but since I'm not a zsh user, I'm not sure exactly how. Want to open a PR?

@ljharb ljharb added shell: zsh pull request wanted This is a great way to contribute! Help us out :-D labels Jan 14, 2018
@revolter
Copy link
Author

revolter commented Jan 15, 2018

I might try, but I can't guarantee.

@JemiloII
Copy link
Contributor

Any update on this? I just started using zsh because bash crashes intellij and I prefer using the terminal in the ide

@revolter
Copy link
Author

I personally didn't start working on it

@FallingSnow
Copy link

I commented out the last line (complete -o default -F __nvm nvm) from /usr/share/nvm/bash_completion and I no long get the error. I assume this breaks auto completion but I never really used it anyway.

@ljharb
Copy link
Member

ljharb commented Mar 20, 2018

@FallingSnow if you don't need autocompletion you can just remove the line from your profile file that sources bash_completion :-p

@pecigonzalo
Copy link

Hi! the problem seems to be that compinit did not happen yet on ZSH so the compdef command does not exist at the point completion is loaded.
I worked around it by doing the following instead of source /usr/share/nvm/init-nvm.sh:

[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
source /usr/share/nvm/nvm.sh
source /usr/share/nvm/install-nvm-exec

# Load compinit/compdef
autoload -U compinit
compinit

# Now load completion
source /usr/share/nvm/bash_completion

@ljharb
Copy link
Member

ljharb commented Mar 29, 2018

@pecigonzalo thanks, that’s great! Could you make a PR to do that in bash_completion, only for zsh, prior to compdef running?

JemiloII added a commit to JemiloII/nvm that referenced this issue Apr 9, 2018
Resolves issue complete:13: command not found: compdef nvm-sh#1707
@JemiloII
Copy link
Contributor

JemiloII commented Apr 9, 2018

Made a PR based off of the solution of @pecigonzalo

Just run the install script in zsh

@pecigonzalo
Copy link

@ljharb Sorry I was unable to do so as I was traveling but someone seems to have taken care of it.

ljharb pushed a commit to JemiloII/nvm that referenced this issue Apr 11, 2018
wzrdtales pushed a commit to wzrdtales/nvm-ng that referenced this issue Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull request wanted This is a great way to contribute! Help us out :-D shell: zsh
Projects
None yet
Development

No branches or pull requests

5 participants