Apt-get is broken after install Google Cloud SDK on Ubuntu 18.04 LTS
Asked Answered
C

7

88

I was installing the Google Cloud SDK on my Ubuntu VM using the following commands

# Add the Cloud SDK distribution URI as a package source
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

# Import the Google Cloud Platform public key
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -

# Update the package list and install the Cloud SDK
sudo apt-get update && sudo apt-get install google-cloud-sdk

and I think its broken now.

 apt-get install unixODBC unixODBC-dev
E: Conflicting values set for option Signed-By regarding source https://packages.cloud.google.com/apt/ cloud-sdk: /usr/share/keyrings/cloud.google.gpg != 
E: The list of sources could not be read.
E: Conflicting values set for option Signed-By regarding source https://packages.cloud.google.com/apt/ cloud-sdk: /usr/share/keyrings/cloud.google.gpg != 
E: The list of sources could not be read.

Is there anyway to fix it so I can continue to download packages.

Congener answered 20/6, 2019 at 4:55 Comment(3)
hey, Vinay Try updating apt by following command: sudo apt update If this will not solve your problem, then try to release all change info by following command: sudo apt update -y --allow-releaseinfo-changeOmidyar
Tried your suggestions. It did not workCongener
In my case, it was a new system and I needed to install "curl" firstSauder
Z
241

I got into a very similar situation today by not following the installation instructions carefully enough. What I think happened is that I accidentally pasted and executed some of the commands that were only supposed to be run if you had trouble with any of the previous steps.(The ones having "Troubleshooting Tip" above them.)

It looks like I "solved" it now by by removing these files

sudo rm /usr/share/keyrings/cloud.google.gpg
sudo rm /usr/share/keyrings/cloud.google.gpg~ 

sudo rm /etc/apt/sources.list.d/google-cloud-sdk.list

and then following the installation instruction again (more carefully this time) to install Google Cloud SDK.

Zonked answered 21/6, 2019 at 14:17 Comment(1)
It also works for google-cloud-cli installation.Grimalkin
C
22

Remove the existing sdk by running single command:

sudo rm /usr/share/keyrings/cloud.google.gpg && sudo rm /usr/share/keyrings/cloud.google.gpg~ && sudo rm /etc/apt/sources.list.d/google-cloud-sdk.list

Install google cloud sdk by running the single command

sudo apt-get install apt-transport-https ca-certificates gnupg && 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-sdk && sudo apt-get install google-cloud-sdk-app-engine-java && sudo apt-get install google-cloud-sdk-app-engine-python && gcloud init

Hope this issue will be fixed.

Contrabassoon answered 2/2, 2022 at 11:24 Comment(0)
O
4

I followed all these commands (for trying to reproduce error in system)

1st command

echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

2nd command

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -

3rd command

sudo apt-get update && sudo apt-get install google-cloud-sdk

4th command

sudo apt-get install unixODBC unixODBC-dev

above command prompted E: Unable to locate package unixODBC E: Unable to locate package unixODBC-dev

Then I installed all the gCloud sdk dependencies By below command 5th command

sudo apt-get install google-cloud-sdk-app-engine-java google-cloud-sdk-app-engine-python google-cloud-sdk-pubsub-emulator google-cloud-sdk-bigtable-emulator google-cloud-sdk-datastore-emulator kubectl

All above commands are given by you except 5th one,

I am unable to reproduce that error in my machine,

But it seems Your apt needs to clean up signed certificats and reconfigure again..

refer below link it might help you.

https://www.fossmint.com/keep-ubuntu-system-clean/

and please let me know about the solution if you got..

feel free to discuss on the same.

Omidyar answered 20/6, 2019 at 6:8 Comment(1)
i got an error E: Unable to locate package unixODBC & E: Unable to locate package unixODBC-devProtection
I
2

I had the same issue, here is how I fixed it

Step 1: Remove sudo rm google-cloud-sdk.list

cd /etc/apt/sources.list.d
sudo rm google-cloud-sdk.list

Step 2: Reinstall Google Cloud again

sudo snap remove google-cloud-sdk # skip if you had installed gcp sdk before
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
sudo 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-sdk
gcloud init

Ref: https://askubuntu.com/a/1389272

Isfahan answered 21/1, 2023 at 10:50 Comment(0)
D
2

This one solved it for me:

curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --yes --dearmor -o /usr/share/keyrings/cloud.google.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list > /dev/null
Dissonant answered 11/2, 2023 at 11:19 Comment(0)
I
0

In case of no such files found, you can remove related link in sources.list or sources.list.save. It worked for me.

Inconsolable answered 24/8, 2022 at 7:39 Comment(0)
S
0

My laptop is running Debian 12 (Bookworm) and I was getting a similar error message after adding the key to the shared keyring and the respective entry in /etc/apt/sources.list.d.

Here are the usual steps:

  1. download the latest key from the location provided by Google in the documentation (https://packages.cloud.google.com/apt/doc/apt-key.gpg), using your favorite method (curl, wget, Ctrl-C/Ctrl-V, whatever)

  2. checked if the key is authentic (gpg --show-keys /path/to/key.gpg and verify the fingerprints)

  3. move the file to /usr/share/keyrings/cloud.google.gpg

  4. create a new apt source file under /etc/apt/sources.list.d with the following entry:

    deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main
    
  5. run apt update

  6. install the desired packages

Pretty much the standard procedure for signed packages, however it was failing at the step 5, saying that the key had an invalid filetype.

It turns out the file provided by Google on that URL has .gpg extension, when in fact it should be .asc, as it contains the ASCII armored version of the GPG key, not the expected binary format.

Giving the GPG key file the correct extension /usr/share/keyrings/cloud.google.asc and changing the reference to the file in /etc/apt/sources.list.d/google-cloud-sdk.list did the trick.

Shakeup answered 12/7, 2023 at 22:1 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.