-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
NVM installation resets completion logic of other commands #2489
Comments
nvm is explicitly unsupported when installed from homebrew; please brew uninstall it, and install it using the approved installation method (curl/wget command in the readme), and then we can confirm if there's a bug in nvm or in homebrew's formula (which already has a few). |
I'm not sure about how compinit works, but if there's a way to improve that completion logic I'm happy to do so. |
Yes. Only minor typo, It would seem that:
|
Confirmed. Installed as you asked. Same issue. |
Is there any way to detect if compinit has been called before? |
Well - one thing seems to be certain. Here is the simplest proof (run in zsh, after $ complete -W "hello world" one
$ one <tab> # to see autocomplete working
$ compinit
$ one <tab> # to see autocomplete NOT working So - in our case, when someone installs nvm and another script that behaves the same as nvm in regards to calling In my case, I fixed it by checking if if [[ -n ${ZSH_VERSION-} ]]; then
autoload -U +X bashcompinit && bashcompinit
if ! command -v compinit > /dev/null; then
autoload -U +X compinit && if [[ ${ZSH_DISABLE_COMPFIX-} = true ]]; then
compinit -u
else
compinit
fi
fi
fi |
Happy to accept a PR that incorporates that check, thanks! |
@DannyBen Let me know if you want me to do the PR. |
Alright - another curious point. We noticed nvm changed this piece of code a little. It would seem that you moved
Yes please. I am not an mvn user. |
There you go #2490. |
For future reference, this is the proper way to install completions in Zsh. |
Operating system and version:
nvm debug
output:nvm ls
output:How did you install
nvm
?Homebrew
What steps did you perform?
Tried to use the completion by pressing tab.
What happened?
No completion defined before NVM completion work!
What did you expect to happen?
To see the list of sub-commands
Is there anything in any of your profile files that modifies the
PATH
?Just adding home/bin and local/bin to the path.
More Details
The whole issue started here DannyBen/alf#39. In my
.zshrc
, I'm sourcing~/.bash_aliases
before NVM completion script which contains:The above also exists in NVM complection script as well. Now the issue is, according to @DannyBen's findings, the issue is that
compinit
should be called exactly once and before any call tocomplete
, otherwise it resets the previous completion logic. (@DannyBen correct me if I'm wrong.)Now, first, is our understanding correct? Second, what's the best solution to fix this issue?
Thanks.
The text was updated successfully, but these errors were encountered: