68

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
  • 69,112
Rupesh
  • 789

6 Answers6

66

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.

41

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
  • 37
0

I got the error E: Conflicting values set for option Signed-By regarding source http://packages.x2go.org/debian/ bullseye: /var/lib/extrepo/keys/x2go.asc != E: The list of sources could not be read. when using sudo apt update after installing X2Go on Debian (https://wiki.x2go.org/doku.php/wiki:repositories:debian). The solution should be similar for Ubuntu users.

Below is what I did to fix the issue.

Add [signed-by=/var/lib/extrepo/keys/x2go.asc] for each repository in /etc/apt/sources.list.d/x2go.list:

# X2Go Repository (release builds)
deb [signed-by=/var/lib/extrepo/keys/x2go.asc] https://packages.x2go.org/debian bullseye extras main
# X2Go Repository (sources of release builds)
deb-src [signed-by=/var/lib/extrepo/keys/x2go.asc] https://packages.x2go.org/debian bullseye extras main

Remove this file:

sudo rm /etc/apt/sources.list.d/extrepo_x2go.sources
baptx
  • 527
-1

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 :-)!

Farlon Souto
  • 159
  • 1
  • 5
-2

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
  • 966