'How to install or uninstall gcloud?
I follow all the steps from here.
At the final step where I run sudo apt-get update && sudo apt-get install google-cloud-sdk
, I get:
Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://ppa.launchpad.net/berglh/pulseaudio-a2dp/ubuntu impish InRelease
Hit:3 http://archive.ubuntu.com/ubuntu impish InRelease
Hit:4 https://packages.cloud.google.com/apt cloud-sdk InRelease
Get:5 http://archive.ubuntu.com/ubuntu impish-updates InRelease [110 kB]
Get:6 http://archive.ubuntu.com/ubuntu impish-backports InRelease [101 kB]
Get:7 http://archive.ubuntu.com/ubuntu impish-security InRelease [110 kB]
Fetched 321 kB in 2s (178 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
google-cloud-sdk is already the newest version (372.0.0-0).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
But, when I run gcloud
it says
Command 'gcloud' not found, but can be installed with:
sudo snap install google-cloud-cli # version 371.0.0, or
sudo snap install google-cloud-sdk # version 371.0.0
See 'snap info <snapname>' for additional versions.
I add
source $HOME/google-cloud-sdk/path.bash.inc
source $HOME/google-cloud-sdk/completion.bash.inc
at the end of my ~/.bashrc
I run source ~/.bashrc
I get:
bash: /home/nitin/google-cloud-sdk/path.bash.inc: No such file or directory
bash: /home/nitin/google-cloud-sdk/completion.bash.inc: No such file or directory
I try to run gcloud
I get:
Command 'gcloud' not found, but can be installed with:
sudo snap install google-cloud-cli # version 371.0.0, or
sudo snap install google-cloud-sdk # version 371.0.0
See 'snap info <snapname>' for additional versions.
Since, I cannot run gcloud
, I cannot even run
gcloud info --format='value(installation.sdk_root)'
gcloud info --format='value(config.paths.global_config_dir)'
and hence cannot complete the steps given here to uninstall the cloud
PLEASE HELP ME SET UP GCLOUD ON MY MACHINE
Solution 1:[1]
There are 2 options on how to install gcloud CLI by checking if your distribution supports signed-by
option. You mentioned that you're using Ubuntu 21.10, meaning that signed-by
option is supported, according to this Ubuntu manuals documentation.
I have replicated the steps and only selected options which supports the signed-by
option.
Upon further reading, apt-key
will be deprecated soon, according to this link. Transitioning to signed-by
would be a better option.
I've used the following commands as they worked on my end:
1. sudo apt-get install apt-transport-https ca-certificates gnupg
2. echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
3. curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
4. sudo apt-get update && sudo apt-get install google-cloud-sdk
5. gcloud init
Let me know if this helps.
Solution 2:[2]
Run these 5 commands to install "gcloud" for Debian/Ubuntu:
sudo apt-get install apt-transport-https ca-certificates gnupg -y
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-cli
*"--console-only" is really important to open a browser properly and you can also use "--no-launch-browser" instead of "--console-only".
gcloud init --console-only
I concatenated these 5 commands above with "&&" as shown below so that you can run only one command:
sudo apt-get install apt-transport-https ca-certificates gnupg -y &&
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list &&
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - &&
sudo apt-get update && sudo apt-get install google-cloud-cli &&
gcloud init --console-only
After running the command above, you will be asked as shown below then, input "y" then, press Enter:
You must log in to continue. Would you like to log in (Y/n)? y
Then, one URL is displayed and you are asked for a "verification code" which you can get from the URL by allowing Google Cloud SDK to access your Google Account:
Go to the following link in your browser:
Enter verification code:
Then, you need to go to the URL above using your browser then, choose one of your google accounts:
Then, press "Allow":
Then, copy the verification code as shown below:
Then, paste the verification code then, press Enter:
Go to the following link in your browser:
Enter verification code: 4/1AX4XfWg7oIOraXFuEGLApi3knvBqvqFgY8bA_6Yj8_osTd4f_FwzrvhicS0
Then, you could log in then, choose one of your projects then, press Enter:
You are logged in as: [[email protected]].
Pick cloud project to use:
1 myproject-817133
2 yourproject-339620
3 Enter a project ID
[4] Create a new project Please enter numeric choice or text value (must exactly match list item): 1
Finally, choosing a default Compute Region and Zone (Optional) finishes the installation:
Do you want to configure a default Compute Region and Zone? (Y/n)?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Robert G |
Solution 2 |