[英]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:在我运行
sudo apt-get update && sudo apt-get install google-cloud-sdk
的最后一步,我得到:
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但是,当我运行
gcloud
时,它说
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在我的 ~/.bashrc 的末尾
I run source ~/.bashrc
我运行
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
我尝试运行
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
,我什至不能运行
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请帮助我在我的机器上设置 GCLOUD
There are 2 options on how to install gcloud CLI by checking if your distribution supports signed-by
option.通过检查您的发行版是否支持
signed-by
选项,有 2 个关于如何安装 gcloud CLI 的选项。 You mentioned that you're using Ubuntu 21.10 , meaning that signed-by
option is supported, according to this Ubuntu manuals documentation .你提到你正在使用Ubuntu 21.10 ,这意味着支持
signed-by
选项,根据这个Ubuntu manuals documentation 。
I have replicated the steps and only selected options which supports the signed-by
option.我已经复制了这些步骤,并且只选择了支持
signed-by
选项。
Upon further reading, apt-key
will be deprecated soon, according to this link .根据此链接,进一步阅读后,
apt-key
将很快被弃用。 Transitioning to signed-by
would be a better option.过渡到
signed-by
将是一个更好的选择。
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.让我知道这是否有帮助。
Run these 5 commands to install "gcloud" for Debian/Ubuntu :运行这 5 个命令为Debian/Ubuntu安装“gcloud” :
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" . * "--console-only"对于正确打开浏览器非常重要,你也可以使用"--no-launch-browser"而不是"--console-only" 。
gcloud init --console-only
I concatenated these 5 commands above with "&&" as shown below so that you can run only one command:我将上面的这 5 个命令与“&&”连接起来,如下所示,这样您就可以只运行一个命令:
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 :运行上面的命令后,系统会如下所示询问您,然后输入“y” ,然后按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:然后,将显示一个 URL,并要求您提供“验证码” ,您可以通过允许Google Cloud SDK访问您的 Google 帐户从 URL 获得该验证码:
Go to the following link in your browser:
Go 到浏览器中的以下链接:
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=pDDwd21KWSbLPwjJ0MCX7JCDwePBzR&prompt=consent&access_type=offline&code_challenge=vZ-2U2YLwHtQPPAVSDjzrfi2uoke4laUwwnOhkOL064&code_challenge_method=S256
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=openid+https%3A%2F% 2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https% 3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=pDDwd21KWSbLPwjJ0MCX7JCDwePBzR&prompt=consent&access_type=offline&code_challenge=vZ-2U2YLwHtQPPAVSDjzrfi2uoke4laUwwnOhkOL064&code_challenge_method=S256
Enter verification code:
输入验证码:
Then, you need to go to the URL above using your browser then, choose one of your google accounts:然后,您需要使用浏览器将上面的 go 转为 URL 然后,选择您的 google 帐户之一:
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:
Go 到浏览器中的以下链接:
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=pDDwd21KWSbLPwjJ0MCX7JCDwePBzR&prompt=consent&access_type=offline&code_challenge=vZ-2U2YLwHtQPPAVSDjzrfi2uoke4laUwwnOhkOL064&code_challenge_method=S256
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=openid+https%3A%2F% 2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https% 3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=pDDwd21KWSbLPwjJ0MCX7JCDwePBzR&prompt=consent&access_type=offline&code_challenge=vZ-2U2YLwHtQPPAVSDjzrfi2uoke4laUwwnOhkOL064&code_challenge_method=S256
Enter verification code: 4/1AX4XfWg7oIOraXFuEGLApi3knvBqvqFgY8bA_6Yj8_osTd4f_FwzrvhicS0
输入验证码:4/1AX4XfWg7oIOraXFuEGLApi3knvBqvqFgY8bA_6Yj8_osTd4f_FwzrvhicS0
Then, you could log in then, choose one of your projects then, press Enter :然后,您可以登录,然后选择您的项目之一,然后按Enter :
You are logged in as: [myappdev@gmail.com].
您登录为:[myappdev@gmail.com]。
Pick cloud project to use:
选择要使用的云项目:
1 myproject-8171331 myproject-817133
2 yourproject-3396202 yourproject-339620
3 Enter a project ID3输入项目 ID
[4] Create a new project Please enter numeric choice or text value (must exactly match list item): 1[4] 创建新项目 请输入数字选择或文本值(必须与列表项完全匹配):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)?
(是/否)?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.