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 | bash


If your are running bash, answer Y when prompted to add gcloud to the PATH and install auto-completion. Don't worry, the installer creates a backup before modifying your .bashrc.


If you are running Zsh, specify the path to your .zshrc when prompted instead of going for the default .bashrc file.

You will then have to manually modify your .zshrc.

The installer adds the following lines:

# The next line updates PATH for the Google Cloud SDK.
source '/path/to/google-cloud-sdk/'

# The next line enables bash completion for gcloud.
source '/path/to/google-cloud-sdk/'

Just replace the bash part in the file names with zsh to use the Zsh specific scripts provided with the SDK.

Oh-my-zsh compatibility

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/ command not found: complete
/path/to/google-cloud-sdk/ parse error near `]]'

I did the following to fix the install.

load the SDK files before Oh-My-Zsh

First, move the lines added by the installer before the source command loading Oh-My-Zsh (source $ZSH/

load missing Zsh module

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 Zsh nor Oh-My-Zsh, but looking at it seems that only compinit is loaded.

You should end up with the following, at the beginning of your .zshrc.

# The next line updates PATH for the Google Cloud SDK.
source '/home/lesaint/GOOGLE_CLOUD/google-cloud-sdk/'

# The next lines enables bash completion in Zsh for gcloud. 
autoload -U compinit compdef
source '/home/lesaint/GOOGLE_CLOUD/google-cloud-sdk/'