Error when installing Google Cloud SDK on Ubuntu, how to fix?
Asked Answered
H

5

9

I'm attempting to set up Google Cloud SDK CLI to manage some compute resources, and I'm just following a guide for this part. I ran this command and it installed lots of stuff successfully but ran into the problem below. Can anyone suggest a solution or how to debug?

$ sudo apt-get update && sudo apt-get install google-cloud-sdk                                   
[sudo] password for #######:                                                                                              
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease                                                                  
Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]                                                         
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]                                                   
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]                                              
Get:5 https://packages.cloud.google.com/apt cloud-sdk InRelease [6349 B]                                                
Ign:6 http://packages.cloud.google.com/apt cloud-sdk-focal InRelease                                                    
Err:7 http://packages.cloud.google.com/apt cloud-sdk-focal Release                                                        
404  Not Found [IP: 216.58.204.238 80]                                                                                
Get:8 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [255 kB]                                       
Get:9 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [7492 B]                                 
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [132 kB]                                  
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [4732 B]                            
Reading package lists... Done                                                                                           
E: The repository 'http://packages.cloud.google.com/apt cloud-sdk-focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.   
Humanity answered 17/7, 2020 at 18:59 Comment(2)
Did you follow step 1 listed here: cloud.google.com/sdk/docs/downloads-apt-get ?Timothytimour
Unfortunately yes. I've seen something to suggest I should run an older version of Ubuntu.Humanity
C
11

I had the same issue with Ubuntu 20. The solution is to install using snap.

snap install google-cloud-sdk --classic

Make sure you have --classic at the end, otherwise you'll get this error:

error: This revision of snap "google-cloud-sdk" was published using classic confinement and thus may perform arbitrary system changes outside of the security sandbox that snaps are usually confined to, which may put your system at risk. If you understand and want to proceed, repeat the command including --classic.

Cymose answered 27/8, 2020 at 14:11 Comment(5)
Thanks. That was exactly what I needed :)Eicher
watch out tho, This revision of snap "google-cloud-sdk" was published using classic confinement and thus may perform arbitrary system changes outside of the security sandbox that snaps are usually confined to, which may put your system at risk.Malvaceous
@Malvaceous what does that mean though? Am I not supposed to trust google?Ashlynashman
imho you can trust google to do what's needed to maximize profit. Conceivably that includes respecting privacy , or not doing so but not getting caught.Malvaceous
This solved it for me, many thanks! +1Starlet
P
1

I don't think it's possible to get gcloud on Ubuntu 20.04.3 with apt, at least not a recent version. I was tempted to get the latest through snap:

sudo snap install google-cloud-sdk --classic

But I can't think of a good reason for "arbitrary system changes outside of the security sandbox". By the way, there's the same warning for node so it's not that uncommon. Nonetheless, I prefer to run it in a container, which by the way, I also do for Node.js.

See an example shell session below, where I get version 360.0.0. I went for slim for now, because the default is around 1GB, but there are plenty of tags to choose from.

docker pull google/cloud-sdk:360.0.0-slim
# run a dummy tail so the container does not exit
docker run --name gcloud -d google/cloud-sdk:360.0.0-slim tail -f /dev/null
# now get a shell into it
docker exec -ti gcloud /bin/bash

root@ff77152a65ee:/# gcloud --version
Google Cloud SDK 360.0.0
alpha 2021.10.04
beta 2021.10.04
bq 2.0.71
core 2021.10.04
gsutil 5.3

Alternatively, for a container that will stop when you exit the shell:

docker run -ti google/cloud-sdk:360.0.0-slim /bin/bash

There's detailed documentation on the official google cloud-sdk docker hub overview page.

I have the following on my ~/.bashrc for quick access into a "gcloud shell":

alias gcloudshell='docker start gcloud && docker exec -ti gcloud /bin/bash'

Note that it can be used multiple times, even if the container is already running.

Peak answered 19/10, 2021 at 17:26 Comment(0)
A
1

Looks like the problem is in not updated documentation on Google. I used this for creating Docker image but I believe it solved normal installation too:

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 467B942D3A79BD29
 RUN apt-get update && apt-get install -y apt-transport-https ca-certificates curl gnupg

 RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | \
     tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \
     apt-key --keyring /usr/share/keyrings/cloud.google.gpg  add - && apt-get update -y && apt-get install google-cloud-cli -y

keep attention on http://packages.cloud.google.com/apt cloud-sdk main. In Google website is http://packages.cloud.google.com/apt cloud-cli main so seems like name of package has been changed from cloud-cli to cloud-sdk.

Almatadema answered 15/4, 2022 at 6:17 Comment(0)
G
1

I get an error when use WSL, and i fix by run:

sudo snap  install google-cloud-sdk --classic
sudo snap  install google-cloud-cli --classic
Gemmiparous answered 4/8, 2023 at 8:24 Comment(0)
H
0

In my case the solution was to install the earlier 18.04 LTS version of Ubuntu (uninstalling 20.04). Having done this the Google Cloud Compute SDK install steps worked successfully.

I found a similar problem / solution described here: https://forums.fast.ai/t/platform-gcp/27375/716

Humanity answered 19/7, 2020 at 16:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.