Unable to use sudo apt-get <command name> in ubuntu 18.04

29,899

Solution 1

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.

Solution 2

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
Share:
29,899

Related videos on Youtube

Rupesh
Author by

Rupesh

I am Rupesh Krishna Jha from IIIT BHUBANESWAR. I am an aspiring FULL STACK WEB DEVELOPER and OPEN SOURCE CONTRIBUTOR.

Updated on September 18, 2022

Comments

  • Rupesh
    Rupesh over 1 year

    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.

    • Kulfy
      Kulfy almost 5 years
      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)
    • Rupesh
      Rupesh almost 5 years
      Hey @Kulfy tried but still getting same error on sudo apt-get <command name>
    • WinEunuuchs2Unix
      WinEunuuchs2Unix almost 5 years
      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.
    • Rupesh
      Rupesh almost 5 years
      Yeah you are wright @WinEunuuchs2Unix, I was trying to install google cloud sdk for ubuntu by following their documentation, here it is cloud.google.com/sdk/docs/quickstart-debian-ubuntu
    • steeldriver
      steeldriver almost 5 years
      Can you edit your question to include the contents of file /etc/apt/sources.list.d/google-cloud-sdk.list please?
    • Rupesh
      Rupesh almost 5 years
      Hi @steeldriver, Updated question with contents of file /etc/apt/sources.list.d/google-cloud-sdk.list .Please help to fix this.
    • steeldriver
      steeldriver almost 5 years
      @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).
  • Rupesh
    Rupesh almost 5 years
    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
  • Oleguer
    Oleguer almost 5 years
    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
  • Rupesh
    Rupesh almost 5 years
    yes, you are correct. After following step 1 and doing step 5, its working. Thanks a lot man.
  • Oleguer
    Oleguer almost 5 years
    You're welcome! Could you mark it as solved?
  • marc.fargas
    marc.fargas about 2 years
    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).