romkatv / zsh4humans

A turnkey configuration for Zsh
MIT License
1.7k stars 112 forks source link

z4h update displays "command not found: complete" with google cli completion #266

Closed iamhsa closed 1 year ago

iamhsa commented 1 year ago

During a z4h update, I observe this :

❯ z4h update
z4h: fetching z4h.zsh
z4h: updating zsh4humans
z4h: updating zsh-history-substring-search
z4h: updating zsh-autosuggestions
z4h: updating zsh-completions
z4h: updating zsh-syntax-highlighting
z4h: updating terminfo
z4h: updating fzf
z4h: updating fzf binary
z4h: updating tmux
z4h: updating ohmyzsh/ohmyzsh
z4h: updating powerlevel10k
z4h: updating gitstatus binary
z4h: initializing zsh
/opt/homebrew/share/google-cloud-sdk/completion.zsh.inc:37: command not found: complete
/opt/homebrew/share/google-cloud-sdk/completion.zsh.inc:62: command not found: complete
/opt/homebrew/share/google-cloud-sdk/completion.zsh.inc:63: command not found: complete
z4h: update successful
z4h: restarting zsh

I don't know if this is something wrong with the file completion.zsh.inc or with zsh4humans.

Reproduce steps (on MacBook)

  1. brew install google-cloud-sdk
  2. exec zsh
  3. gcloud <tab> --> not functional
  4. In ~/.zshrc add this two lines (as almost shown in brew install output)
    z4h source "$HOMEBREW_PREFIX/share/google-cloud-sdk/path.zsh.inc"
    z4h source "$HOMEBREW_PREFIX/share/google-cloud-sdk/completion.zsh.inc"
  5. exec zsh
  6. gcloud <tab> --> Functional
  7. z4h update
  8. See command not found: complete 3 times on output
juangiordana commented 1 year ago

I've seen this error too and tracked it down to the NVM completion script:

https://github.com/nvm-sh/nvm/blob/7b530edd3a2a3ebc976c455394f7245827194da7/bash_completion#L99

romkatv commented 1 year ago
/opt/homebrew/share/google-cloud-sdk/completion.zsh.inc:37: command not found: complete
/opt/homebrew/share/google-cloud-sdk/completion.zsh.inc:62: command not found: complete
/opt/homebrew/share/google-cloud-sdk/completion.zsh.inc:63: command not found: complete

Thanks for reporting this. Fixed.

z4h source "$HOMEBREW_PREFIX/share/google-cloud-sdk/path.zsh.inc"

Are you sure you need this? Try removing this line, restart your terminal and see if there are any commands you want to run that aren't working. If there are none, you don't need this line. (In general, don't add anything to your zsh startup files unless you can clearly see the positive effect of it.)

z4h source "$HOMEBREW_PREFIX/share/google-cloud-sdk/completion.zsh.inc"

This is now automatic. You can remove this line from .zshrc.

romkatv commented 1 year ago

I've seen this error too and tracked it down to the NVM completions script:

https://github.com/nvm-sh/nvm/blob/7b530edd3a2a3ebc976c455394f7245827194da7/bash_completion#L99

If you can describe all steps that lead to an error, I might be able to do something about it.

juangiordana commented 1 year ago

If you can describe all steps that lead to an error, I might be able to do something about it.

It used to happen just opening a terminal and running z4h update but I didn't reported it because I thought it might have been on my end. I just thought that adding some info to the discussion might help.

Thanks for fixing it.

romkatv commented 1 year ago

My offer still stands: if you can describe all steps leading to the nvm error, I might be able to fix it.

iamhsa commented 1 year ago

Thanks for reporting this. Fixed.

Thanks you for your quick response.

Are you sure you need this?

I'm pretty sur I don't need it. It was just to respect brew install output

z4h update no longer display command not found: complete πŸ‘

On the other hand, if I remove z4h source "$HOMEBREW_PREFIX/share/google-cloud-sdk/completion.zsh.inc" from my ~/.zshrc I no longer have the completions, so for now I keep it. I suppose, this is something wrong on my side.

iamhsa commented 1 year ago

In fact, even with z4h source "$HOMEBREW_PREFIX/share/google-cloud-sdk/completion.zsh.inc" in ~/.zshrccompletion isn't functional.

romkatv commented 1 year ago

I'm pretty sur I don't need it. It was just to respect brew install output

If doing something was a good default, brew install would've done it automatically.

z4h update no longer display command not found: complete πŸ‘

Thanks for verifying.

On the other hand, if I remove z4h source "$HOMEBREW_PREFIX/share/google-cloud-sdk/completion.zsh.inc" from my ~/.zshrc I no longer have the completions

Ouch. Fixed.

iamhsa commented 1 year ago

Works, like a charm!

I let issue open as @juangiordana seem to have a similar issue with nvm

Thank you so much for the quick fix, your time, and advice.

romkatv commented 1 year ago

I let issue open as @juangiordana seem to have a similar issue with nvm

They haven't submitted an issue report (what they do, what they see and what they expect). They are free to do so in a new issue.

Closing as done.

juangiordana commented 1 year ago

This fixed it.

edshamis commented 1 year ago

I observe this after the fix, when completing gcloud in tmux:

❯ gcloud zstyle:5: no such builtin: -T zstyle:5: no such builtin: -s zstyle:5: no such builtin: -s zstyle:5: no such builtin: -a zstyle:5: no such builtin: -a _next_label:9: bad math expression: operator expected at funcstack ...' zstyle:5: no such builtin: -s zstyle:5: no such builtin: -s zstyle:5: no such builtin: -s zstyle:5: no such builtin: -s zstyle:5: no such builtin: -s zstyle:5: no such builtin: -a zstyle:5: no such builtin: -a zstyle:5: no such builtin: -a zstyle:5: no such builtin: -s _description:71: bad math expression: operator expected atcomp_ignor...' _description:set:102: bad option: -M

It works ok out of tmux. I've got this in .zshrc:

zstyle ':z4h:' start-tmux 'no'

I've got gcloud installed manually (not with brew) so I added this to . zshrc:

z4h source ~/.gcloud/path.zsh.inc
z4h source ~/.gcloud/completion.zsh.inc

@romkatv tell me if you need more info. Thanks!

romkatv commented 1 year ago

Please open a new issue and describe all steps necessary to reproduce this.

edshamis commented 1 year ago

Please open a new issue and describe all steps necessary to reproduce this.

It was some misunderstood of mine. Sorry for bothering