How do I fix "Unknown error executing gpgv" when doing sudo apt-get update?

15,235

Solution 1

I have two solutions:

  • Solution #1 (Recommended ):

    Just open a terminal and run the following commands:

    sudo apt-get clean

    sudo rm /var/lib/apt/lists/*

    sudo rm /var/lib/apt/lists/partial/*

    sudo apt-get clean

    sudo apt-get update

    Done! When running those sudo rm ... commands, don't worry about errors or warnings.

  • Solution #2:

    1. First remove all ppa repositories in Update Manager -> Settings -> Other Software;

    2. sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak

    3. sudo touch /etc/apt/sources.list

    4. sudo apt-get update

    5. sudo mv /etc/apt/sources.list.bak /etc/apt/sources.list

    6. sudo apt-get update

    7. Now add all your ppa repos back again.

    8. sudo apt-get update

    Done!

Solution 2

Your original error :

mv: cannot move `lists' to `lists.old/lists': Directory not empty

can be addressed by adding a timestamp to the directory rename as you can see below. Also, by adding a && in between each line will demarcate each command will allow you to cut and paste entire set of below commands from your notes back into a terminal

sudo apt-get clean && \
cd /var/lib/apt && \
sudo mv lists lists.old_`date '+%Y%m%d_%H%M%S'`   && \
sudo mkdir -p lists/partial && \
sudo apt-get clean && \
sudo apt-get update

another approach is to put it into a script which will exit on error ... vi myscript.sh

#!/bin/bash 
set -o errexit

sudo apt-get clean 
cd /var/lib/apt 
sudo mv lists lists.old_`date '+%Y%m%d_%H%M%S'`   
sudo mkdir -p lists/partial 
sudo apt-get clean 
sudo apt-get update
Share:
15,235

Related videos on Youtube

Kapil Anand
Author by

Kapil Anand

Updated on September 18, 2022

Comments

  • Kapil Anand
    Kapil Anand over 1 year

    I got the following error

    Reading package lists... Done
    W: GPG error: http://extras.ubuntu.com oneiric Release: Unknown error executing gpgv
    executing gpgv
    ----
    ----
    W: GPG error: http://archive.ubuntu.com oneiric-updates Release: Unknown error executing gpgv
    

    Then after googling it I found and followed the following instruction but that caused one error:

    **sudo -i
    apt-get clean
    cd /var/lib/apt
    mv lists lists.old
    mkdir -p lists/partial
    apt-get clean
    apt-get update**
    

    While running I got the error:

    kapil@ubuntu:/var/lib/apt$ sudo mv lists lists.old
    mv: cannot move `lists' to `lists.old/lists': Directory not empty
    

    So once again running the update command I got the same error again. Please help me what should I do?


    I did the following on your advice and it showed the following

    root@ubuntu:/home/kapil# df -h
    
    Filesystem            Size  Used Avail Use% Mounted on
    
    /dev/loop0             15G  4.7G  8.8G  35% /
    
    udev                  1.5G  4.0K  1.5G   1% /dev
    
    tmpfs                 591M  880K  590M   1% /run
    
    none                  5.0M     0  5.0M   0% /run/lock
    
    none                  1.5G  488K  1.5G   1% /run/shm
    
    /dev/sda5             229G  221G  7.2G  97% /host
    
    /dev/sda1             100M   25M   76M  25% /media/System Reserved
    
    root@ubuntu:/home/kapil# ls -al /var/lib/apt/
    
    total 68
    
    drwxr-xr-x  7 root root  4096 2012-04-08 09:53 .
    
    drwxr-xr-x 58 root root  4096 2012-03-28 09:59 ..
    
    -rw-r--r--  1 root root   203 2012-03-24 13:18 cdroms.list
    
    -rw-r--r--  1 root root  7261 2012-04-06 15:27 extended_states
    
    drwxr-xr-x  2 root root  4096 2011-10-12 10:27 keyrings
    
    drwxr-xr-x  3 root root 16384 2012-04-14 06:26 lists
    
    
    drwxr-xr-x  4 root root 20480 2012-04-08 07:46 lists.old
    
    drwxr-xr-x  3 root root  4096 2011-10-12 10:27 mirrors
    
    drwxr-xr-x  2 root root  4096 2012-03-24 14:39 periodic*
    

    When I followed the above instruction it showed following warnings first :

    root@ubuntu:/home/kapil# sudo apt-get clean
    
    root@ubuntu:/home/kapil# sudo rm /var/lib/apt/lists/*
    
    rm: cannot remove `/var/lib/apt/lists/partial': Is a directory
    
    root@ubuntu:/home/kapil# sudo rm /var/lib/apt/lists/partial/*
    
    root@ubuntu:/home/kapil# sudo apt-get clean
    
    root@ubuntu:/home/kapil# sudo apt-get update
    

    After this it again showed the error :

    Reading package lists... Done
    
    W: GPG error: http//archive.canonical.com oneiric Release: Unknown error executing gpgv
    
    W: GPG error: http//extras.ubuntu.com oneiric Release: Unknown error executing gpgv
    
    W: GPG error: http//archive.ubuntu.com oneiric Release: Unknown error executing gpgv
    
    W: GPG error: http//archive.ubuntu.com oneiric-backports Release: Unknown error executing gpgv
    
    W: GPG error: http//archive.ubuntu.com oneiric-security Release: Unknown error executing gpgv
    
    W: GPG error: http//archive.ubuntu.com oneiric-proposed Release: Unknown error executing gpgv
    
    W: GPG error: http//archive.ubuntu.com oneiric-updates Release: Unknown error executing gpgv
    

    What to do now?

    • jippie
      jippie about 12 years
      Long shot, but please check file system usage with df -h. Also check if lists.old already exists. In that case move it somewhere else.
    • Kapil Anand
      Kapil Anand about 12 years
      Thanks for ur answer but im a amateur in ubuntu ...can u give me step wise intruction for above advice because im not allowed to move a folder/file in root folder location of "var/lib/apt"
    • jippie
      jippie about 12 years
      Enter the following on the command line, then update your question with what you found: df -h and ls -al /var/lib/apt/
    • Kapil Anand
      Kapil Anand about 12 years
      done ... i hv updated in above problem to show u the output..
    • jippie
      jippie about 12 years
      You're currently booted from a (install) CD?
    • Kapil Anand
      Kapil Anand about 12 years
      no i have installed ubuntu 11.10 in windows ...no booting from a CD
    • jippie
      jippie about 12 years
      I find the /dev/loop0 for the root filesystem fishy. Can you give us the output to mount and losetup -a ?
  • Kapil Anand
    Kapil Anand about 12 years
    i have mentioned the output ...problem still persists ...any help will be greatfull .kindly help
  • Seyed Mohammad
    Seyed Mohammad about 12 years
    The commands I provided are slightly different from those you posted in the question. Carefully follow the commands I have provided. These should work, because I've used this method to solve GPG-errors many times and it has always worked for me.
  • Kapil Anand
    Kapil Anand about 12 years
    i have updated my question by including ur instruction tht u just said...check the o/p whihch im getting .....@seyed
  • Kapil Anand
    Kapil Anand about 12 years
    plz reply to my question @ seyed mohammad
  • Seyed Mohammad
    Seyed Mohammad about 12 years
    Hmm, strange! Currently I don't have any clue why this didn't fix the issue. I will come back as soon as I find anything useful.
  • Seyed Mohammad
    Seyed Mohammad about 12 years
    OK, I have edited my solution by providing another fix. If this one doesn't work too, I'm afraid I'm out of solutions for you! But I'm almost sure that one of these solutions should work for you.