"sudo: gcloud: command not found" when running Google Cloud SDK

Viewed 17932

Running Ubuntu.

Installed Google Cloud SDK via:

$ sudo curl https://sdk.cloud.google.com | sudo bash 
$ exec -l $SHELL 

Running "gcloud" works just fine.

Running "sudo gcloud" results in the following error:

sudo: gcloud: command not found

Oddly, when I installed Google Cloud SDK via apt-get, "sudo gcloud" works just fine. Unfortunately I cannot use Google Cloud SDK from apt-get as kubectl does not come with it and cannot be installed with the apt-get version.

Why would "gcloud" work and not "sudo gcloud"?

EDIT 5/21/2017: The following works if I manually set the path with the sudo command. I'd rather not do this every time though.

sudo env "PATH=$PATH" gcloud
3 Answers

I got it working by applying those 2 changes:

  1. Stop the VM instance and edit it to select "give full access to all APIs", then restart.

  2. In the terminal, as root user, run: apt-get install google-cloud-sdk

While installing Just modify your rc path with your shell, by default it takes root.

as like in bold line

enter a path to an rc file to update, or leave blank to use [/root/.zshrc]: /home/one/.zshrc

Backing up [/home/one/.zshrc] to [/home/one/.zshrc.backup]. [/home/one/.zshrc] has been updated

Related