apt --fix-broken 安装不起作用

apt --fix-broken 安装不起作用

我正在使用 Ubuntu 20.04。当我执行以下命令时:

sudo apt-get install build-essential

我得到输出:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version (12.8ubuntu1.1).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 fontconfig:i386 : Depends: libfreetype6:i386 (>= 2.8.1) but 2.6.1-0.1ubuntu2 is to be installed
 libcairo2:i386 : Depends: libfreetype6:i386 (>= 2.9.1) but 2.6.1-0.1ubuntu2 is to be installed
 libfontconfig1:i386 : Depends: libfreetype6:i386 (>= 2.9.1) but 2.6.1-0.1ubuntu2 is to be installed
 libfreetype6 : Breaks: libfreetype6:i386 (!= 2.10.1-2ubuntu0.1) but 2.6.1-0.1ubuntu2 is to be installed
 libfreetype6:i386 : Depends: libpng12-0:i386 (>= 1.2.13-4) but it is not installable
                     Breaks: libfreetype6 (!= 2.6.1-0.1ubuntu2) but 2.10.1-2ubuntu0.1 is to be installed
 libharfbuzz0b:i386 : Depends: libfreetype6:i386 (>= 2.9.1) but 2.6.1-0.1ubuntu2 is to be 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... failed.
The following packages have unmet dependencies:
 fontconfig:i386 : Depends: libfreetype6:i386 (>= 2.8.1) but 2.6.1-0.1ubuntu2 is installed
 libcairo2:i386 : Depends: libfreetype6:i386 (>= 2.9.1) but 2.6.1-0.1ubuntu2 is installed
 libfontconfig1:i386 : Depends: libfreetype6:i386 (>= 2.9.1) but 2.6.1-0.1ubuntu2 is installed
 libfreetype6 : Breaks: libfreetype6:i386 (!= 2.10.1-2ubuntu0.1) but 2.6.1-0.1ubuntu2 is installed
 libfreetype6:i386 : Depends: libpng12-0:i386 (>= 1.2.13-4) but it is not installable
                     Breaks: libfreetype6 (!= 2.6.1-0.1ubuntu2) but 2.10.1-2ubuntu0.1 is installed
 libharfbuzz0b:i386 : Depends: libfreetype6:i386 (>= 2.9.1) but 2.6.1-0.1ubuntu2 is installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependencies

我试图用这些 libfree 包在 Ubuntu 20.04 上设置 Modelsim,但似乎我把一切都搞砸了。有什么办法可以完全摆脱它们吗?我尝试删除它们,命令的输出

sudo dpkg --configure -a

现在是空的,但我仍然收到上述错误。

答案1

我在网上找到了一些可能有用的资源。

解决方案 1

作为甜品他们的答案,他们按照以下步骤修复了这个问题:

第一次运行:

dpkg -l | grep ^iU | awk '{print $2}' | xargs sudo dpkg --purge

如果输出是:

dpkg: error: --purge needs at least one package name argument

Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !

然后转到下一个解决方案,或者运行:

sudo apt update && sudo apt upgrade

完毕!


解决方案 2

作为阿姆兰·萨哈·昆杜他们的答案超级用户,则需要清除 的内容/var/lib/dpkg/status

要完成上述操作:

  1. 通过运行以下命令备份文件:

    sudo cp -r /var/lib/dpkg/status $HOME
    
  2. 然后通过运行以下命令清除内容:

    echo > /var/lib/dpkg/status
    
  3. 运行之后:

    sudo apt update && sudo apt upgrade
    

你可以搜索问题以获得更多解决方案。

答案2

看起来您尝试在 16.04(xenial)系统上安装 20.04(focal)软件包。

你已经意识到,混合使用不同版本的 Ubuntu 软件包可能会破坏你的系统。如果你需要较新的软件包,则必须运行较新版本的 Ubuntu。

由于您的系统上这两种软件包混合在一起(我们称之为 Frankensystem),最简单的选择是备份您的数据,然后重新安装 Ubuntu。

有技能和耐心的人完全有可能仔细阅读每条错误消息并将每个焦点包降级回 xenial。显然,没有单一、简单的命令可以做到这一点。备份数据后,请随意尝试 - 如果无法做到,请重新安装。

相关内容