I'm working with a fresh install of 18.04.1 from which I have removed certain packages that communicate asynchronously with other hosts, having pinned them, along with certain other packages, for non-installation. Every time I run (a) dpkg -i, (b) apt-get install, or (c) aptitude install, the lock files /var/lib/dpkg/lock and /var/cache/apt/archives/lock are re-created and I must remove them manually before I can run a, b, or c again. This never happened before 18.04.1, nor on any issue of 16.04. Q: What's broken, and how can I avoid the necessity of removing the lock files manually?

dpkg --configure -a does not help, and it does not remove the lock files. If it finds something to do, it fixes it, creates /var/lib/dpkg/lock and just leaves that lock file there, while exiting normally.

ps aux | grep -E 'apt|dkpg' yields

    root     24494  0.0  0.0  14428  1064 pts/0    S+   11:48   0:00 grep --color=auto -E apt|dkpg

i.e., there are no hangover processes that might account for the problem.

As user535733 requested, here is a terminal session that demonstrates the phenomenon. (By the way, I have now fresh-installed 2 hosts with 18.04.1 and they both show the same troubling behavior.)

~  root@sea{3}# date; ls -l /var/lib/dpkg/lock /var/cache/apt/archives/lock
Tue Aug 14 08:52:46 EDT 2018
ls: cannot access '/var/cache/apt/archives/lock': No such file or directory
-rw-r----- 1 root root 0 Aug 11 04:48 /var/lib/dpkg/lock
~  root@sea{3}# ls -d /var/cache/apt/archives
/var/cache/apt/archives/
~  root@sea{3}# apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
~  root@sea{3}# date; ls -l /var/lib/dpkg/lock /var/cache/apt/archives/lock
Tue Aug 14 08:53:58 EDT 2018
-rw-r----- 1 root root 0 Aug 14 08:53 /var/cache/apt/archives/lock
-rw-r----- 1 root root 0 Aug 11 04:48 /var/lib/dpkg/lock
~  root@sea{3}# date; ls -l /var/lib/dpkg/lock /var/cache/apt/archives/lock; rm /var/lib/dpkg/lock /var/cache/apt/archives/lock; 
Tue Aug 14 08:54:36 EDT 2018
-rw-r----- 1 root root 0 Aug 14 08:53 /var/cache/apt/archives/lock
-rw-r----- 1 root root 0 Aug 11 04:48 /var/lib/dpkg/lock
~  root@sea{3}# date; ls -l /var/lib/dpkg/lock /var/cache/apt/archives/lock; rm /var/lib/dpkg/lock /var/cache/apt/archives/lock; 
Tue Aug 14 08:54:44 EDT 2018
ls: cannot access '/var/lib/dpkg/lock': No such file or directory
ls: cannot access '/var/cache/apt/archives/lock': No such file or directory
rm: cannot remove '/var/lib/dpkg/lock': No such file or directory
rm: cannot remove '/var/cache/apt/archives/lock': No such file or directory
~  root@sea{3}# apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
~  root@sea{3}# date; ls -l /var/lib/dpkg/lock /var/cache/apt/archives/lock; rm /var/lib/dpkg/lock /var/cache/apt/archives/lock; 
Tue Aug 14 08:55:09 EDT 2018
-rw-r----- 1 root root 0 Aug 14 08:54 /var/cache/apt/archives/lock
-rw-r----- 1 root root 0 Aug 14 08:54 /var/lib/dpkg/lock
~  root@sea{3}# date; ls -l /var/lib/dpkg/lock /var/cache/apt/archives/lock; rm /var/lib/dpkg/lock /var/cache/apt/archives/lock; 
Tue Aug 14 08:56:20 EDT 2018
ls: cannot access '/var/lib/dpkg/lock': No such file or directory
ls: cannot access '/var/cache/apt/archives/lock': No such file or directory
rm: cannot remove '/var/lib/dpkg/lock': No such file or directory
rm: cannot remove '/var/cache/apt/archives/lock': No such file or directory
~  root@sea{3}# dpkg -r telnet
(Reading database ... 310184 files and directories currently installed.)
Removing telnet (0.17-41) ...
Processing triggers for man-db (2.8.3-2) ...
~  root@sea{3}# date; ls -l /var/lib/dpkg/lock /var/cache/apt/archives/lock; rm /var/lib/dpkg/lock /var/cache/apt/archives/lock; 
Tue Aug 14 08:56:53 EDT 2018
ls: cannot access '/var/cache/apt/archives/lock': No such file or directory
-rw-r----- 1 root root 0 Aug 14 08:56 /var/lib/dpkg/lock
rm: cannot remove '/var/cache/apt/archives/lock': No such file or directory
~  root@sea{3}# date; ls -l /var/lib/dpkg/lock /var/cache/apt/archives/lock; rm /var/lib/dpkg/lock /var/cache/apt/archives/lock; 
Tue Aug 14 08:57:17 EDT 2018
ls: cannot access '/var/lib/dpkg/lock': No such file or directory
ls: cannot access '/var/cache/apt/archives/lock': No such file or directory
rm: cannot remove '/var/lib/dpkg/lock': No such file or directory
rm: cannot remove '/var/cache/apt/archives/lock': No such file or directory
~  root@sea{3}# dpkg -r telnet
dpkg: warning: ignoring request to remove telnet, only the config
 files of which are on the system; use --purge to remove them too
~  root@sea{3}# dpkg -i telnet
dpkg: error: cannot access archive 'telnet': No such file or directory
~  root@sea{3}# apt-get -y install telnet
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  telnet
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 67.1 kB of archives.
After this operation, 165 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 telnet amd64 0.17-41 [67.1 kB]
Fetched 67.1 kB in 0s (207 kB/s)
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
Selecting previously unselected package telnet.
(Reading database ... 310185 files and directories currently installed.)
Preparing to unpack .../telnet_0.17-41_amd64.deb ...
Unpacking telnet (0.17-41) ...
Setting up telnet (0.17-41) ...
update-alternatives: using /usr/bin/telnet.netkit to provide /usr/bin/telnet (telnet) in auto mode
Processing triggers for man-db (2.8.3-2) ...
~  root@sea{3}# date; ls -l /var/lib/dpkg/lock /var/cache/apt/archives/lock; rm /var/lib/dpkg/lock /var/cache/apt/archives/lock; 
Tue Aug 14 08:58:21 EDT 2018
-rw-r----- 1 root root 0 Aug 14 08:57 /var/cache/apt/archives/lock
-rw-r----- 1 root root 0 Aug 14 08:58 /var/lib/dpkg/lock
~  root@sea{3}# date; ls -l /var/lib/dpkg/lock /var/cache/apt/archives/lock; rm /var/lib/dpkg/lock /var/cache/apt/archives/lock; 
Tue Aug 14 08:58:24 EDT 2018
ls: cannot access '/var/lib/dpkg/lock': No such file or directory
ls: cannot access '/var/cache/apt/archives/lock': No such file or directory
rm: cannot remove '/var/lib/dpkg/lock': No such file or directory
rm: cannot remove '/var/cache/apt/archives/lock': No such file or directory
~  root@sea{3}# apt-get -y install telnet
Reading package lists... Done
Building dependency tree       
Reading state information... Done
telnet is already the newest version (0.17-41).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
~  root@sea{3}# date; ls -l /var/lib/dpkg/lock /var/cache/apt/archives/lock; rm /var/lib/dpkg/lock /var/cache/apt/archives/lock; 
Tue Aug 14 08:59:25 EDT 2018
-rw-r----- 1 root root 0 Aug 14 08:59 /var/cache/apt/archives/lock
-rw-r----- 1 root root 0 Aug 14 08:59 /var/lib/dpkg/lock
~  root@sea{3}# date; ls -l /var/lib/dpkg/lock /var/cache/apt/archives/lock; rm /var/lib/dpkg/lock /var/cache/apt/archives/lock; 
Tue Aug 14 08:59:43 EDT 2018
ls: cannot access '/var/lib/dpkg/lock': No such file or directory
ls: cannot access '/var/cache/apt/archives/lock': No such file or directory
rm: cannot remove '/var/lib/dpkg/lock': No such file or directory
rm: cannot remove '/var/cache/apt/archives/lock': No such file or directory
~  root@sea{3}#

I suspect it may have something to do with the fact that I have pinned the following packages for non-installation, just as I have done without problems in the past:

    apport-gtk
    apturl
    kerneloops-daemon
    landscape-common
    libfam0
    libreoffice-calc
    libreoffice-core
    libreoffice-gnome
    libreoffice-gtk
    libreoffice-style-elementary
    libreoffice-writer
    lightdm-gtk-greeter-settings
    light-locker
    lxd
    nagios-images
    nagios-plugins
    popularity-contest
    postgresql
    postgresql-9.5
    postgresql-9.6
    postgresql-client-9.5
    postgresql-client-9.6
    postgresql-contrib-9.5
    postgresql-contrib-9.6
    python3-distupgrade
    python3-distupgrade
    python3-update-manager
    python-pycurl
    samba-common
    samba-common-bin
    smbclient
    snap-confine
    snapd
    software-center
    software-center-aptdaemon-plugins
    squashfs-tools
    squashfs-tools
    ubuntu-release-upgrader-core
    ubuntu-release-upgrader-gtk
    ubuntu-server
    ubuntu-standard
    unattended-upgrades
    update-manager
    update-manager-core
    update-manager-gnome
    update-notifier
    update-notifier-common
    update-notifier-core
    virtualbox-guest-dkms
    virtualbox-guest-utils
    virtualbox-guest-x11
    whoopsie
  • 1
    I have pinned unattended-upgrades for non-installation, it is not installed, and the problem still exists. – Steve Newcomb Aug 7 at 20:40
  • Erm, just to eliminate what could be an XY-problem: exactly what problems do you experience? Please add the relevant details to your question. – zwets Aug 7 at 20:58
  • I'm asking because you mention that aptitude and dpkg "work just fine". – zwets Aug 7 at 22:19
  • I will try to be clearer. (1) I run one of: dpkg, aptitude, apt-get. It works. (2) I run any one of them again, but it refuses because either /var/lib/dpkg/lock or /var/cache/apt/archives/lock exists. (3) I remove the offending file(s). (4) [start again at #1]. – Steve Newcomb Aug 8 at 13:02
  • Please modify your question to include that information. Comments are for transient information. Run a sudo dpkg --configure -a to make sure that your packages are in a consistent state. Next time the blockage happens, run ps aux | grep -E 'apt|dkpg' and include the output in your question. – zwets Aug 8 at 13:38

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.