陷入依赖项循环 - ubuntu 22.04

陷入依赖项循环 - ubuntu 22.04

我不知何故陷入了包依赖循环。当我尝试升级我的包时出现以下情况:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libapt-pkg6.0 : Depends: libgcrypt20 (>= 1.10.0) but 1.9.4-3ubuntu3 is installed
                 Depends: libzstd1 (>= 1.5.2) but 1.4.8+dfsg-3build1 is installed
                 Recommends: apt (>= 2.5.3) but 2.4.8 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

所以我尝试了sudo apt --fix-broken install

sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... failed.
The following packages have unmet dependencies:
 libapt-pkg6.0 : Depends: libgcrypt20 (>= 1.10.0) but 1.9.4-3ubuntu3 is installed
                 Depends: libzstd1 (>= 1.5.2) but 1.4.8+dfsg-3build1 is installed
                 Recommends: apt (>= 2.5.3) but 2.4.8 is installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependencies

然后我尝试删除/清除该包sudo apt purge libapt-pkg6.0:amd64

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 apt : Depends: libapt-pkg6.0 (>= 2.4.8) but it is not going to be installed
 apt-utils : Depends: libapt-pkg6.0 (>= 2.4.8) but it is not going to be installed
 packagekit : Depends: libapt-pkg6.0 (>= 1.9.2) but it is not going to be installed
 python3-apt : Depends: libapt-pkg6.0 (>= 1.9.11~) but it is not going to be installed
 ubuntu-advantage-tools : Depends: libapt-pkg6.0 (>= 0.8.0) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

输出apt policy libapt-pkg6.0

libapt-pkg6.0:
  Installed: 2.5.3
  Candidate: 2.5.3
  Version table:
 *** 2.5.3 100
        100 /var/lib/dpkg/status
     2.4.8 500
        500 http://ch.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
     2.4.5 500
        500 http://ch.archive.ubuntu.com/ubuntu jammy/main amd64 Packages

我也尝试了其他方法,但似乎我陷入了这种境地。任何建议都会有帮助。

答案1

好的,我想我找到了一个解决方案:

首先我用的是:

sudo dpkg -r --force-depends libapt-pkg6.0:amd64

删除依赖包

然后我下载了正确的版本:

wget http://archive.ubuntu.com/ubuntu/pool/main/a/apt/libapt-pkg6.0_2.4.5_amd64.deb

然后安装它:

sudo dpkg -i libapt-pkg6.0_2.4.5_amd64.deb

重新启动系统,之后更新和升级再次正常运行

答案2

看起来您在某个时候将 22.10(kinetic)包安装到了 22.04(jammy)系统上。

22.10 中的 libapt-pkg6.0 = 版本 2.5.3。

教训:除非您是专家,否则切勿混合使用来自 Ubuntu 不同版本的软件包。

您有三个选择:

  1. 如果您不知道事情是怎么发生的,或者不想花几个小时学习如何修复它,那么是时候重新安装 22.04(或 22.10)了。

  2. 或者,另一个解决方案是恢复使用 22.10。这更复杂,因为您无法do-release-upgrade再使用,因为您的软件包具有未满足的依赖关系。这是否可行取决于您造成的损害程度、您是如何造成的,以及您是否有修复它的技能。它需要手动修复您的源,然后使用dist-upgrade。这不是受支持的升级路径,因此如果您遇到问题,我们建议您重新安装。

  3. 最复杂且需要最高技能的解决方案是卸载所有 22.10 软件包并从 20.04 存储库重新安装。此解决方案有一个学习曲线,需要一定的 apt 技能。重新安装几乎肯定更快、更简单。

相关内容