Why did "E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem" appear?

For Ubuntu Desktop 18:04 for update I use:

  • sudo apt update
  • sudo apt upgrade

But suddenly for the latter now arises:

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem

So executing that command I got:

sudo dpkg --configure -a
dpkg: dependency problems prevent configuration of linux-generic-hwe-18.04:
 linux-generic-hwe-18.04 depends on linux-headers-generic-hwe-18.04 (= 5.4.0.80.90~18.04.72); however:
  Version of linux-headers-generic-hwe-18.04 on system is 5.4.0.77.86~18.04.69.

dpkg: error processing package linux-generic-hwe-18.04 (--configure):
 dependency problems - leaving unconfigured
Setting up linux-modules-5.4.0-80-generic (5.4.0-80.90~18.04.1) ...
Setting up linux-image-5.4.0-80-generic (5.4.0-80.90~18.04.1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-5.4.0-77-generic
I: /initrd.img.old is now a symlink to boot/initrd.img-5.4.0-77-generic
I: /vmlinuz is now a symlink to boot/vmlinuz-5.4.0-80-generic
I: /initrd.img is now a symlink to boot/initrd.img-5.4.0-80-generic
Setting up linux-modules-extra-5.4.0-80-generic (5.4.0-80.90~18.04.1) ...
Setting up linux-image-generic-hwe-18.04 (5.4.0.80.90~18.04.72) ...
Processing triggers for linux-image-5.4.0-80-generic (5.4.0-80.90~18.04.1) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.4.0-80-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.4.0-80-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-80-generic
Found initrd image: /boot/initrd.img-5.4.0-80-generic
Found linux image: /boot/vmlinuz-5.4.0-77-generic
Found initrd image: /boot/initrd.img-5.4.0-77-generic
Found linux image: /boot/vmlinuz-5.4.0-73-generic
Found initrd image: /boot/initrd.img-5.4.0-73-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done
Errors were encountered while processing:
 linux-generic-hwe-18.04

So executing

  • sudo apt update
  • sudo apt upgrade

The second now fails with:

sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 linux-generic-hwe-18.04 : Depends: linux-headers-generic-hwe-18.04 (= 5.4.0.80.90~18.04.72) but 5.4.0.77.86~18.04.69 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

so

sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  linux-headers-5.4.0-73-generic linux-hwe-5.4-headers-5.4.0-73 linux-image-5.4.0-73-generic linux-modules-5.4.0-73-generic
  linux-modules-extra-5.4.0-73-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  linux-headers-5.4.0-80-generic linux-headers-generic-hwe-18.04 linux-hwe-5.4-headers-5.4.0-80
The following NEW packages will be installed:
  linux-headers-5.4.0-80-generic
The following packages will be upgraded:
  linux-headers-generic-hwe-18.04 linux-hwe-5.4-headers-5.4.0-80
2 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
2 not fully installed or removed.
Need to get 0 B/12.3 MB of archives.
After this operation, 85.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 210068 files and directories currently installed.)
Preparing to unpack .../linux-hwe-5.4-headers-5.4.0-80_5.4.0-80.90~18.04.1_all.deb ...
Unpacking linux-hwe-5.4-headers-5.4.0-80 (5.4.0-80.90~18.04.1) over (5.4.0-80.90~18.04.1) ...

So

  • sudo apt update
  • sudo apt upgrade

All work fine

Question

  • Why did the E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem message appear?

E: dpkg was interrupted

You must have either turned off the computer while there was an ongoing update or software installation, or have killed the ongoing update process, and as a result, the package manager was interrupted, and the packages were corrupted.

Something like this may have happened if you turned off the computer while an unattended update (automatic updates in the background) was running.