为什么出现“E: dpkg 被中断,您必须手动运行‘sudo dpkg --configure -a’来纠正此问题”?

为什么出现“E: dpkg 被中断,您必须手动运行‘sudo dpkg --configure -a’来纠正此问题”?

对于 Ubuntu Desktop 18:04 更新我使用:

  • sudo apt 更新
  • sudo apt 升级

但现在后者突然出现:

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

因此执行该命令我得到:

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

因此执行

  • sudo apt 更新
  • sudo apt 升级

第二个现在失败了:

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).

所以

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) ...

所以

  • sudo apt 更新
  • sudo apt 升级

一切正常

问题

  • 为什么E:dpkg 中断,您必须手动运行“sudo dpkg --configure -a”来解决问题是否出现消息?

答案1

E: dpkg 被中断

您肯定在正在进行更新或软件安装时关闭了计算机,或者终止了正在进行的更新过程,结果导致包管理器中断,并且包损坏。

如果您在无人值守更新(后台自动更新)运行时关闭计算机,则可能会发生类似情况。

答案2

sudo apt-get install -y surfshark

出现此错误:E:dpkg 被中断,您必须手动运行“sudo dpkg --configure -a”来纠正问题。

sudo dpkg --configure -a

运行此命令时出现此错误:dpkg:错误:解析文件“/var/lib/dpkg/updates/0078”第 0 行附近:字段名称“#padding”中的换行符

cd /var/lib/dpkg/updates/0078
rm -rf 0078

之后我将删除该文件。

sudo apt-get install -y surfshark

再次出现此错误:E:dpkg 被中断,您必须手动运行“sudo dpkg --configure -a”来纠正问题。

sudo dpkg --configure -a

它将配置 dpkg

After All My Error is solved

相关内容