安装/卸载 snapd 时遇到问题。
由于某种原因,我的 Ubuntu 16.04 上的 snap 版本不正确:
snap --version
snap 2.31.1~14.04
snapd unavailable
series -
因此我想使用以下命令手动重新安装 snad:
sudo apt-get install snapd
并得到错误:
Errors were encountered while processing:
/var/cache/apt/archives/snapd_2.33.1~14.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
我决定尝试使用此命令来卸载此版本:
sudo apt purge snapd ubuntu-core-launcher squashfs-tools
给我这个结果:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'ubuntu-core-launcher' is not installed, so not removed
The following packages will be REMOVED:
snapd* squashfs-tools*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 79,3 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 312065 files and directories currently installed.)
Removing snapd (2.31.1~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
dpkg: squashfs-tools: dependency problems, but removing anyway as you requested:
snapd depends on squashfs-tools; however:
Package squashfs-tools is to be removed.
Removing squashfs-tools (1:4.3-3ubuntu2.16.04.1) ...
Processing triggers for man-db (2.7.5-1) ...
Errors were encountered while processing:
snapd
E: Sub-process /usr/bin/dpkg returned an error code (1)
命令:
apt-get -f install
也无济于事。
~$ apt-cache policy snapd
snapd:
Installed: 2.31.1~14.04
Candidate: 2.33.1~14.04
Version table:
2.33.1~14.04 500
500 http://archive.ubuntu.com/ubuntu trusty-proposed/universe amd64 Packages
2.32.9 500
500 http://ru.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
2.32.9~14.04 500
500 http://archive.ubuntu.com/ubuntu trusty-updates/universe amd64 Packages
*** 2.31.1~14.04 100
100 /var/lib/dpkg/status
2.0.2 500
500 http://ru.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
如果您知道发生了什么事以及如何解决这个问题,请帮助我:)
编辑:
我在源列表中拥有的可信赖的软件包:
deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
答案1
我解决这个问题的版本:
- 从您的 中删除/注释所有不必要的可信来源
/etc/apt/sources.list
。 - 运行
sudo apt-get update
并验证apt-cache policy snapd
现在是否有Candidate: 2.32.9
您需要的。尝试sudo apt install --reinstall snapd
。 - 可选。如果仍然有
Sub-process /usr/bin/dpkg returned an error code (1)
错误,请清理cd var/lib/dpkg/info
并sudo rm ./snapd*
重新安装 snapdsudo apt install --reinstall snapd
。 - 验证安装的版本是否为 2.32.9
snap --version
。