ITADN

gcloud-cli: zsh completion symlink in site-functions doesn't follow #compdef convention

#258782Closedandrewhsu 创建于 2026-04-11
stale
A
andrewhsucommented
## 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: ```zsh # 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`: ```zsh #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: ```zsh 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 1. Don't symlink `completion.zsh.inc` into `site-functions/` — it's not a `compinit`-compatible file. Instead, document that users should source it directly. 2. 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 ```
关闭于 2026-05-10 3 条评论