Description
The gcloud-cli cask symlinks completion.zsh.inc into site-functions as _google_cloud_sdk:
/opt/homebrew/share/zsh/site-functions/_google_cloud_sdk -> /opt/homebrew/Caskroom/gcloud-cli/561.0.0/google-cloud-sdk/completion.zsh.inc
However, this file doesn't follow the zsh completion convention that compinit expects for files in site-functions/. It uses bashcompinit and bash-style complete commands instead of starting with a #compdef header:
# What the file has:
autoload -U +X bashcompinit && bashcompinit
...
complete -o nospace -o default -F _python_argcomplete "gcloud"
# What compinit expects for autoloading:
#compdef gcloud bq gsutil
For comparison, a properly formatted completion file like _gh:
#compdef gh
compdef _gh gh
Impact
Running compinit finds the file but doesn't know which commands it provides completions for, so gcloud <Tab> doesn't work. Users must source the file explicitly as a workaround:
source /opt/homebrew/share/zsh/site-functions/_google_cloud_sdk
This is the same underlying issue as #143596, which was closed without addressing the convention mismatch.
Possible fixes
- Don't symlink
completion.zsh.inc into site-functions/ — it's not a compinit-compatible file. Instead, document that users should source it directly.
- Add a thin wrapper in
site-functions/_google_cloud_sdk that has the proper #compdef gcloud bq gsutil header and sources the upstream file.
Environment
macOS, Homebrew, gcloud-cli 561.0.0, zsh 5.9
Description
The
gcloud-clicask symlinkscompletion.zsh.incintosite-functionsas_google_cloud_sdk:However, this file doesn't follow the zsh completion convention that
compinitexpects for files insite-functions/. It usesbashcompinitand bash-stylecompletecommands instead of starting with a#compdefheader:For comparison, a properly formatted completion file like
_gh:#compdef gh compdef _gh ghImpact
Running
compinitfinds the file but doesn't know which commands it provides completions for, sogcloud <Tab>doesn't work. Users must source the file explicitly as a workaround:source /opt/homebrew/share/zsh/site-functions/_google_cloud_sdkThis is the same underlying issue as #143596, which was closed without addressing the convention mismatch.
Possible fixes
completion.zsh.incintosite-functions/— it's not acompinit-compatible file. Instead, document that users should source it directly.site-functions/_google_cloud_sdkthat has the proper#compdef gcloud bq gsutilheader and sources the upstream file.Environment