To install the Google Cloud SDK, you can follow the installation guidelines available online. But if you are running Ubuntu and uses Oh-My-Zsh (or to some extent, Zsh alone), automatic installation won’t work and you need to do some manual steps.
Install via the bash installer
Run the following command to download and install the SDK on your disk.
curl https://sdk.cloud.google.com | bash
If your are running
Y when prompted to add
gcloud to the
PATH and install auto-completion. Don’t worry, the installer creates a backup before modifying your
If you are running
Zsh, specify the path to your
.zshrc when prompted instead of going for the default
You will then have to manually modify your
The installer adds the following lines:
# The next line updates PATH for the Google Cloud SDK. source '/path/to/google-cloud-sdk/path.bash.inc' # The next line enables bash completion for gcloud. source '/path/to/google-cloud-sdk/completion.bash.inc'
Just replace the
bash part in the file names with
zsh to use the Zsh specific scripts provided with the SDK.
I use Oh-My-Zsh as a shell and unfortunately, the procedure above did not work for me.
When loading a new shell, I got errors such as the following and command line completion did not work.
/path/to/google-cloud-sdk/completion.bash.inc:8: command not found: complete /path/to/google-cloud-sdk/completion.bash.inc:19: parse error near `]]'
I did the following to fix the install.
load the SDK files before
First, move the lines added by the installer before the source command loading
Then two lines to tell
Zsh to load and init some specific modules required for completion to work before the
source command for completion. I a no expert with
Oh-My-Zsh, but looking at
oh-my-zsh.sh it seems that only
compinit is loaded.
You should end up with the following, at the beginning of your
# The next line updates PATH for the Google Cloud SDK. source '/home/lesaint/GOOGLE_CLOUD/google-cloud-sdk/path.zsh.inc' # The next lines enables bash completion in Zsh for gcloud. autoload -U compinit compdef compinit source '/home/lesaint/GOOGLE_CLOUD/google-cloud-sdk/completion.zsh.inc'