运行 apt upgrade、apt install、dpkg --configure -a 或 sudo apt install -f 时出现“E: 子进程 /usr/bin/dpkg 返回错误代码 (1)”

运行 apt upgrade、apt install、dpkg --configure -a 或 sudo apt install -f 时出现“E: 子进程 /usr/bin/dpkg 返回错误代码 (1)”

每当我尝试运行以下任何命令时都会收到错误

  • sudo apt upgrade

  • sudo apt install chrome-gnome-shell

  • dpkg --configure -a

  • sudo install -f

(可能还有其他一些)

错误sudo apt upgrade在这里:

intoo@hilavitkutin:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
5 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up grub-efi-amd64 (2.02-2ubuntu8.4) ...
dpkg: error processing package grub-efi-amd64 (--configure):
 installed grub-efi-amd64 package post-installation script subprocess returned error exit status 10
Setting up gdm3 (3.28.3-0ubuntu18.04.1) ...
dpkg: error processing package gdm3 (--configure):
 installed gdm3 package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of grub-efi-amd64-signed:
 grub-efi-amd64-signed depends on grub-efi-amd64 | grub-pc; however:
  Package grub-efi-amd64 is not configured yet.
  Package grub-pc is not installed.

dpkg: error processing package grub-efi-amd64-signed (--configure):
 dependency problems - leaving unconfigured
Setting up unattended-upgrades (1.1ubuntu1.18.04.5) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                          dpkg: error processing package unattended-upgrades (--configure):
 installed unattended-upgrades package post-installation script subprocess returned error exit status 10
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of shim-signed:
 shim-signed depends on grub-efi-amd64-signed; however:
  Package grub-efi-amd64-signed is not configured yet.

dpkg: error processing package shim-signed (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 grub-efi-amd64
 gdm3
 grub-efi-amd64-signed
 unattended-upgrades
 shim-signed
E: Sub-process /usr/bin/dpkg returned an error code (1)

我已尽一切努力来解决这个问题,但我在网上找到的办法都没有用,因为他们依赖于此,dpkg --configure -a而且只会给出几乎相同的错误,正如您在此处看到的:

intoo@hilavitkutin:~$ sudo dpkg --configure -a
Setting up grub-efi-amd64 (2.02-2ubuntu8.4) ...
dpkg: error processing package grub-efi-amd64 (--configure):
 installed grub-efi-amd64 package post-installation script subprocess returned error exit status 10
Setting up gdm3 (3.28.3-0ubuntu18.04.1) ...
dpkg: error processing package gdm3 (--configure):
 installed gdm3 package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of grub-efi-amd64-signed:
 grub-efi-amd64-signed depends on grub-efi-amd64 | grub-pc; however:
  Package grub-efi-amd64 is not configured yet.
  Package grub-pc is not installed.

dpkg: error processing package grub-efi-amd64-signed (--configure):
 dependency problems - leaving unconfigured
Setting up unattended-upgrades (1.1ubuntu1.18.04.5) ...
dpkg: error processing package unattended-upgrades (--configure):
 installed unattended-upgrades package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of shim-signed:
 shim-signed depends on grub-efi-amd64-signed; however:
  Package grub-efi-amd64-signed is not configured yet.

dpkg: error processing package shim-signed (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 grub-efi-amd64
 gdm3
 grub-efi-amd64-signed
 unattended-upgrades
 shim-signed

我还发现了以下几行:

dpkg: dependency problems prevent configuration of grub-efi-amd64-signed:
 grub-efi-amd64-signed depends on grub-efi-amd64 | grub-pc; however:
  Package grub-efi-amd64 is not configured yet.
  Package grub-pc is not installed.

我尝试过sudo apt install grub-pc,但它只给出了这个:

intoo@hilavitkutin:~$ sudo apt install grub-pc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 grub-pc : Depends: grub-common (= 2.02-2ubuntu8) but 2.02-2ubuntu8.4 is to be installed
           Depends: grub2-common (= 2.02-2ubuntu8) but 2.02-2ubuntu8.4 is to be installed
           Depends: grub-pc-bin (= 2.02-2ubuntu8) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

最后它说我损坏了软件包,但我进入了恢复模式并恢复了损坏的软件包。第一次它卡住了 3 个小时,所以我重启了电脑并再次尝试。那次没有任何问题。

另外,从错误报告来看,我似乎有一些错误版本的东西。

我正在使用 Ubuntu 18.04。

我真的很想修复它,因为如果它一直坏着我甚至无法升级。

sudo su -
cd /boot/efi/EFI
mv ubuntu ubuntu-old

跑步apt install -f可以达到这个效果。

root@hilavitkutin:/boot/efi/EFI# apt install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
5 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up grub-efi-amd64 (2.02-2ubuntu8.4) ...
dpkg: error processing package grub-efi-amd64 (--configure):
 installed grub-efi-amd64 package post-installation script subprocess returned error exit status 10
Setting up gdm3 (3.28.3-0ubuntu18.04.1) ...
dpkg: error processing package gdm3 (--configure):
 installed gdm3 package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of grub-efi-amd64-signed:
 grub-efi-amd64-signed depends on grub-efi-amd64 | grub-pc; however:
  Package grub-efi-amd64 is not configured yet.
  Package grub-pc is not installed.

dpkg: error processing package grub-efi-amd64-signed (--configure):
 dependency problems - leaving unconfigured
Setting up unattended-upgrades (1.1ubuntu1.18.04.5) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                          dpkg: error processing package unattended-upgrades (--configure):
 installed unattended-upgrades package post-installation script subprocess returned error exit status 10
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of shim-signed:
 shim-signed depends on grub-efi-amd64-signed; however:
  Package grub-efi-amd64-signed is not configured yet.

dpkg: error processing package shim-signed (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 grub-efi-amd64
 gdm3
 grub-efi-amd64-signed
 unattended-upgrades
 shim-signed
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

我已经遇到过两次类似的问题,仍然不确定究竟是什么原因造成的,但我按照这个答案中的说明进行操作,允许安装有问题的 grub-efi-amd64-signed 包,然后 apt 能够继续安装其余的包。

https://askubuntu.com/a/1032156/31861

之前发生这种情况时,我正在进行发行版升级,但这只是一次常规更新,其中包括将软件包更新至 grub-efi-amd64-signed 1.93.7,因此似乎是一个持续存在的问题https://bugs.launchpad.net/ubuntu/+source/grub2-signed/+bug/1753518

答案2

我有同样的问题,尝试在你的电脑(文件系统)中找到它的包/文件并删除它,我的意思是这个包,通过终端,然后再一次安装所有这些包,再一次,可能

sudo apt remove -y  grub-efi-amd64 gdm3 grub-efi-amd64-signed unattended-upgrades shim-signed
sudo apt autoremove -y
sudo apt update
sudo apt upgrade -y 

如果您看到消息,(建议autoremove)尝试一下,但在此操作之后,再做upgrade一次,如果autoremove在终端中建议是钢,只需查找当前文件或包的位置,(您无法制作autoremove),然后手动将其从文件系统中删除:

sudo rm -r /**/grub-efi-amd64
sudo rm -r /**/grub-efi-amd64-signed
sudo rm -r /**/unattended-upgrades
sudo rm -r /**/shim-signed
sudo rm -r /run/gdm3

在此过程中不要注销或关闭电源。

在所有过程之后尝试制定此计划:

sudo apt update
sudo apt upgrade -y

如果需要的话

sudo apt install -y  grub-efi-amd64 gdm3 grub-efi-amd64-signed unattended-upgrades shim-signed

相关内容