从 14.04 升级到 16.04 后,apt-get 不知怎么在我的系统上出现了问题xenial
,我不知道该如何修复它。这是我(升级后apt update
)得到的结果。
有人能提供一些关于如何修复它的建议吗?
$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
libsimgearcore3.4.0v5 libsimgearscene3.4.0v5 linux-headers-4.4.0-97 linux-headers-4.4.0-97-generic linux-image-4.4.0-97-generic linux-image-extra-4.4.0-97-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 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 snapd (2.28.5~14.04) ...
Failed to execute operation: No such file or directory
dpkg: error processing package snapd (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
snapd
E: Sub-process /usr/bin/dpkg returned an error code (1)
我也尝试运行apt -f install
并得到以下结果:
$ sudo apt -f install
[sudo] password for ron:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libsimgearcore3.4.0v5 libsimgearscene3.4.0v5 linux-headers-4.4.0-97 linux-headers-4.4.0-97-generic linux-image-4.4.0-97-generic linux-image-extra-4.4.0-97-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up snapd (2.28.5~14.04) ...
Failed to execute operation: No such file or directory
dpkg: error processing package snapd (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
snapd
E: Sub-process /usr/bin/dpkg returned an error code (1)
哪里$ sudo dpkdg --configure -a
给了我:
$ sudo dpkg --configure -a
Setting up snapd (2.28.5~14.04) ...
Failed to execute operation: No such file or directory
dpkg: error processing package snapd (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
snapd
返回位置sudo apt-get --remove purge snapd
:
$ sudo apt-get --remove purge snapd
[sudo] password for ron:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
cgroup-lite libsimgearcore3.4.0v5 libsimgearscene3.4.0v5 linux-generic-lts-xenial linux-headers-4.4.0-97 linux-headers-4.4.0-97-generic linux-image-4.4.0-97-generic
linux-image-extra-4.4.0-97-generic squashfs-tools
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
snapd*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 74.5 MB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 661915 files and directories currently installed.)
Removing snapd (2.28.5~14.04) ...
Failed to stop snapd.autoimport.service: Unit snapd.autoimport.service not loaded.
Failed to stop snapd.socket: Unit snapd.socket not loaded.
Failed to stop snapd.service: Unit snapd.service not loaded.
dpkg: error processing package snapd (--purge):
subprocess installed pre-removal script returned error exit status 5
Errors were encountered while processing:
snapd
sudo aE: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
这个答案@vskubriev 可能掌握着强制删除的关键。
本质上:在shebang后面
添加。然后运行以下命令。exit 0
/var/lib/dpkg/info/snapd.prerm
dpkg --purge --force-all snapd
apt-get update
也可以通过运行重新安装apt-get install snapd
如果@vskubriev 的回答有帮助的话请在那里点赞,而不是在这里。
答案2
看起来您已经从安装了 snapd 的 14.04 升级到了 16.04,并且由于某种原因 snapd 包没有被替换,从而导致这个问题,您可以执行以下操作来删除该包:
#: sudo rm /var/lib/dpkg/info/snapd.p*rm #:sudo apt-get remove --purge snapd
这将删除删除前/删除后脚本,并应允许在脚本失败时删除包。如果您确实需要 snapd(因为您之前安装了一些 snap 包或类似的东西),您只需运行:
#:sudo apt更新 #:sudo apt 安装 snapd