3

I am getting the above error while installing Google cloud sdk.

I entered below command in terminal:

curl https://sdk.cloud.google.com | bash

Thanks

Lopson
  • 1,142
  • 1
  • 7
  • 18
  • Run `source ~/.bash_profile` see [here](https://stackoverflow.com/questions/31037279/gcloud-command-not-found-while-installing-google-cloud-sdk). – YaguraStation Nov 06 '18 at 10:54
  • thanks for your response I read the other post and tried this command already but it did not fix the issue. It seems like issue is with permission to my profile so may be i need chmode command to give permission to the user. I will try your command and chmod as well and update here if that helps – Cosmos Innovations Limted Nov 06 '18 at 21:48

3 Answers3

1

TL;DR (copy and paste in 2 steps, )

Step 1 (gcloud will prompt for input):

sudo chown $(whoami):staff ~/.bash_profile
curl https://sdk.cloud.google.com | bash

Step 2:

sudo chown root:staff ~/.bash_profile
source ~/.bash_profile

Explanation:

~/.bash_profile is owned by the rootuser, so it requires sudo and therefore the root password. The command curl https://sdk.cloud.google.com | bash does not have permission to edit it. My solution here was to change ownership of the file for the installation of gcloud and then revert it back to root after the installation was completed.

  1. Change ownership of the file sudo chown $(whoami):staff ~/.bash_profile

    • This command will probably prompt for password
    • $(whoami) will be replaced by the currently logged in user.
    • staff is just the already existing group
  2. Run installation command and proceed to respond input prompts $ curl https://sdk.cloud.google.com | bash
  3. Reset root ownership to the profile for security reasons sudo chown root:staff ~/.bash_profile
  4. Reload shell to make gcloud commands available $ source ~/.bash_profile

Important Note

I tried sudo curl https://sdk.cloud.google.com | bash but it did not work for some reason.

eriel marimon
  • 764
  • 10
  • 24
0

This most likely happened when the SDK's installation script attempted to modify your .bashrc in order to add gcloud (and others) to your profile's PATH environment variable. The script attempted to change the file, but didn't have enough permissions to do it, thus failed. I recommend making sure you or the user installing the SDK can modify their own .bashrc file.

Lopson
  • 1,142
  • 1
  • 7
  • 18
0

TL;DR (copy and paste)

curl https://sdk.cloud.google.com | sudo bash

Explanation

On my first answer I noted that

sudo curl https://sdk.cloud.google.com | bash

didn't work, adding the sudo in front of bash seems to have the intended effect, rather than on the curl command. This should be simpler than changing ownership back and forth.

eriel marimon
  • 764
  • 10
  • 24