55

When I am trying to use any command like sudo apt-get update then I am getting

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

Here is my cd to /usr/share/keyrings/

rupeshiya@devil:/usr/share/keyrings$ ls
ubuntu-archive-keyring.gpg          ubuntu-esm-keyring.gpg
ubuntu-archive-removed-keys.gpg     ubuntu-fips-keyring.gpg
ubuntu-cloudimage-keyring.gpg       ubuntu-fips-updates-keyring.gpg
ubuntu-cloudimage-removed-keys.gpg  ubuntu-master-keyring.gpg

Here is my contents of file /etc/apt/sources.list.d/google-cloud-sdk.list

rupeshiya@devil:/etc/apt/sources.list.d$ cat google-cloud-sdk.list 
deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main
deb https://packages.cloud.google.com/apt cloud-sdk main
deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main
deb http://packages.cloud.google.com/apt cloud-sdk main

How can I fix this? I am not a very experienced Ubuntu user but trying to implement things in Ubuntu.

Braiam
  • 67,791
  • 32
  • 179
  • 269
Rupesh
  • 651
  • 2
    Try running curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - (do not remove hyphen) – Kulfy Jul 06 '19 at 15:43
  • Hey @Kulfy tried but still getting same error on sudo apt-get – Rupesh Jul 06 '19 at 16:34
  • I take it you were trying to install the Google Cloud SDK and it failed along the way? If so do you have a link to the installation instructions you were following? perhaps they missed something out. – WinEunuuchs2Unix Jul 06 '19 at 16:44
  • Yeah you are wright @WinEunuuchs2Unix, I was trying to install google cloud sdk for ubuntu by following their documentation, here it is https://cloud.google.com/sdk/docs/quickstart-debian-ubuntu – Rupesh Jul 06 '19 at 18:50
  • Can you [edit] your question to include the contents of file /etc/apt/sources.list.d/google-cloud-sdk.list please? – steeldriver Jul 06 '19 at 21:04
  • Hi @steeldriver, Updated question with contents of file /etc/apt/sources.list.d/google-cloud-sdk.list .Please help to fix this. – Rupesh Jul 09 '19 at 09:33
  • @Rupesh thanks - so I wonder if the issue is that you have both a [signed-by=xxxxx] and a regular unsigned version of the same repositories (hence the messages xxxxx !=)? I suggest commenting out the unsigned entries (the 2nd and 4th lines). – steeldriver Jul 09 '19 at 12:34

5 Answers5

50

You are very likely to have followed the Cloud SDK install instructions to the letter. Some steps are alternative (ie, you do one or the other).

As a result, your /etc/apt/sources.list.d/google-cloud-sdk.list will have a duplicate entry:

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

As you can see, both lines are the same except that one specifies a keyring file and the other does not (so it uses the default). There is your conflict.

You shall remove the line containing the 'signed-by' and you would be good to go.

36

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
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
2

I had the same problem. I think the issue is you are missing this file: cloud.google.gpg in /usr/share/keyrings/

To fix it you could do:

  1. Remove google-cloud-sdk so you can use apt-get again:

    cd /etc/apt/sources.list.d

    sudo rm google-cloud-sdk.list

  2. Install curl (in case you dont have it):

    sudo apt-get install curl

  3. Copy the key:

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

  4. Add source to list again:

    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

    echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

  5. Install the sdk again:

    sudo apt-get update

    sudo apt-get install google-cloud-sdk

I think this is what worked for me but I am also not very exerienced so please if someone can provide further detail, that would be ideal.

Hope it works :)

Oleguer
  • 29
  • Followed as per your instruction but now on 5 th step sudo apt-get update getting error as given rupeshiya@devil:/etc/apt/sources.list.d$ sudo apt-get update 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 – Rupesh Jul 09 '19 at 13:56
  • Hmm that's strange... Could you attemp step 1 and then step 5 and make sure google-cloud-sdk.list gets removed from the folder. Lets see if we do this we can at least sudo apt-get update – Oleguer Jul 09 '19 at 17:32
  • yes, you are correct. After following step 1 and doing step 5, its working. Thanks a lot man. – Rupesh Jul 09 '19 at 18:46
  • You're welcome! Could you mark it as solved? – Oleguer Jul 09 '19 at 19:30
  • Step 4 is reintroducing the problem again, by creating two sources.list entries for the same repo but with different options (one has signed-by set, the other does not). – marc.fargas Mar 14 '22 at 16:00
0

These conflicts are typically caused by having multiple entries spreading in one or many .list files.

It's a tough exercise, but, do the following:

  1. Locate the .list files in your system:

    sudo find / -type f -name "*.list"

  2. Or, even better: Locate the .list files containing an entry that looks like the one showing up in the apt-get error messages (e.g: one for the microsoft repos):

    sudo find / -type f -name "*.list" -exec grep -l "packages.microsoft.com" {} +

  3. You gotta select one of the files where the entry of interest (i.e. the repository URL) will remain. Comment out with a hashtag (# ) all the other ones, being them in the same file or in other files. Prefer to preserve the an entry containing a signed-by tag.

  4. Ensure that the referenced .gpg file is present in the path referenced by the signed-by tag. If it's not, you must obtain and install the .gpg file, because this file is a signature that is checked by apt-get whenever downloading/updating content from a signed repository.

This might be enough: Run sudo apt-get update again. And good luck :-)!

-1

Delete all of the Google related files from /etc/apt/sources.list.d/:

rm -i /etc/apt/sources.list.d/*google*

Then try to reinstall them again.

moo
  • 878