Debian:“apt install build-essential”因未满足依赖关系而失败

Debian:“apt install build-essential”因未满足依赖关系而失败

使用 Debian Stretch v9.11。

我尝试安装 build-essential,但由于未满足依赖关系而失败:

sudo apt install build-essential
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:
 build-essential : Depends: libc6-dev but it is not going to be installed or
                            libc-dev
                   Depends: g++ (>= 4:6.3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

apt-cache 策略显示:

apt-cache policy
Package files:
 100 /var/lib/dpkg/status
     release a=now
 500 http://security.debian.org/debian-security stretch/updates/non-free amd64 Packages
     release v=9,o=Debian,a=oldstable,n=stretch,l=Debian-Security,c=non-free,b=amd64
     origin security.debian.org
 500 http://security.debian.org/debian-security stretch/updates/contrib amd64 Packages
     release v=9,o=Debian,a=oldstable,n=stretch,l=Debian-Security,c=contrib,b=amd64
     origin security.debian.org
 500 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
     release v=9,o=Debian,a=oldstable,n=stretch,l=Debian-Security,c=main,b=amd64
     origin security.debian.org
 500 http://deb.debian.org/debian stretch/non-free amd64 Packages
     release v=9.11,o=Debian,a=oldstable,n=stretch,l=Debian,c=non-free,b=amd64
     origin deb.debian.org
 500 http://deb.debian.org/debian stretch/contrib amd64 Packages
     release v=9.11,o=Debian,a=oldstable,n=stretch,l=Debian,c=contrib,b=amd64
     origin deb.debian.org
 500 http://deb.debian.org/debian stretch/main amd64 Packages
     release v=9.11,o=Debian,a=oldstable,n=stretch,l=Debian,c=main,b=amd64
     origin deb.debian.org

/etc/apt/sources.list 中有以下内容:

# deb cdrom:[Debian GNU/Linux 9.5.0 _Stretch_ - Official amd64 DVD Binary-1 20180714-10:25]/ stretch contrib main

deb http://deb.debian.org/debian stretch main contrib non-free
deb-src http://deb.debian.org/debian stretch main contrib non-free

# deb http://deb.debian.org/debian stretch-updates main
# deb-src http://deb.debian.org/debian stretch-updates main


# deb http://deb.debian.org/debian-security/ stretch/updates main
# deb-src http://deb.debian.org/debian-security/ stretch/updates main

deb http://security.debian.org/debian-security stretch/updates main contrib non-free
deb-src http://security.debian.org/debian-security stretch/updates main contrib non-free

# add backports
# deb http://ftp.debian.org/debian stretch-backports main


# stretch-updates, previously known as 'volatile'
# A network mirror was not selected during install.  The following entries
# are provided as examples, but you should amend them as appropriate
# for your mirror of choice.
#
# deb http://deb.debian.org/debian/ stretch-updates main contrib
# deb-src http://deb.debian.org/debian/ stretch-updates main contrib

编辑1:apt-cache policy libc6-dev 显示:

apt-cache policy libc6-dev
libc6-dev:
  Installed: (none)
  Candidate: 2.24-11+deb9u4
  Version table:
     2.24-11+deb9u4 500
        500 http://deb.debian.org/debian stretch/main amd64 Packages
     2.24-11+deb9u1 500
        500 http://security.debian.org/debian-security stretch/updates/main amd64 Packages

apt-cache policy g++显示:

apt-cache policy g++
g++:
  Installed: (none)
  Candidate: 4:6.3.0-4
  Version table:
     4:6.3.0-4 500
        500 http://deb.debian.org/debian stretch/main amd64 Packages

编辑2:deb http://ftp.de.debian.org/debian buster main曾经/etc/apt/sources.list.d/.mc.list

我记得,有一次我必须安装一个更新的 mc,它有特定的错误修复。

编辑3:

apt update
Get:1 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Ign:2 http://deb.debian.org/debian stretch InRelease
Hit:3 http://deb.debian.org/debian stretch Release
Fetched 94.3 kB in 1s (69.7 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.

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.

apt-get install --fix-broken
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

编辑4:

sudo apt install libc6-dev g++
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:
libc6-dev : Depends: libc6 (= 2.24-11+deb9u4) but 2.27-6 is to be installed
Depends: libc-dev-bin (= 2.24-11+deb9u4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

sudo apt install build-essential
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:
build-essential : Depends: libc6-dev but it is not going to be installed or
libc-dev
Depends: g++ (>= 4:6.3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

编辑5

sudo aptitude -f install build-essential
The following NEW packages will be installed:
build-essential dpkg-dev{a} fakeroot{a} g++{a} g++-6{a} libalgorithm-diff-perl{a} libalgorithm-diff-xs-perl{a} libalgorithm-merge-perl{a} libc-dev-bin{ab} libc6-dev{ab} libdpkg-perl{a} libfakeroot{a} libfile-fcntllock-perl{a} libstdc++-6-dev{a} linux-libc-dev{a} manpages-dev{a} 0 packages upgraded, 16 newly installed, 0 to remove and 0 not upgraded. Need to get 17.9 MB of archives. After unpacking 69.7 MB will be used.
The following packages have unmet dependencies:
libc6-dev : Depends: libc6 (= 2.24-11+deb9u4) but 2.27-6 is installed
libc-dev-bin : Depends: libc6 (< 2.25) but 2.27-6 is installed
The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) build-essential [Not Installed]
2) g++ [Not Installed]
3) g++-6 [Not Installed]
4) libc-dev-bin [Not Installed]
5) libc6-dev [Not Installed]
6) libstdc++-6-dev [Not Installed]

Leave the following dependencies unresolved:
7) dpkg-dev recommends build-essential



Accept this solution? [Y/n/q/?]
The following NEW packages will be installed:
dpkg-dev{a} fakeroot{a} libalgorithm-diff-perl{a}
libalgorithm-diff-xs-perl{a} libalgorithm-merge-perl{a}
libdpkg-perl{a} libfakeroot{a} libfile-fcntllock-perl{a}
manpages-dev{a}
The following packages are RECOMMENDED but will NOT be installed: build-essential
0 packages upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 5,267 kB of archives. After unpacking 8,773 kB will be used.
Do you want to continue? [Y/n/?]
Get: 1 http://deb.debian.org/debian stretch/main amd64 libdpkg-perl all 1.18.25 [1,287 kB]
Get: 2 http://deb.debian.org/debian stretch/main amd64 dpkg-dev all 1.18.25 [1,595 kB]
Get: 3 http://deb.debian.org/debian stretch/main amd64 libfakeroot amd64 1.21-3.1 [45.7 kB]
Get: 4 http://deb.debian.org/debian stretch/main amd64 fakeroot amd64 1.21-3.1 [85.6 kB]
Get: 5 http://deb.debian.org/debian stretch/main amd64 libalgorithm-diff-perl all 1.19.03-1 [48.7 kB]
Get: 6 http://deb.debian.org/debian stretch/main amd64 libalgorithm-diff-xs-perl amd64 0.04-4+b2 [11.6 kB]
Get: 7 http://deb.debian.org/debian stretch/main amd64 libalgorithm-merge-perl all 0.08-3 [12.7 kB]
Get: 8 http://deb.debian.org/debian stretch/main amd64 libfile-fcntllock-perl amd64 0.22-3+b2 [35.3 kB]
Get: 9 http://deb.debian.org/debian stretch/main amd64 manpages-dev all 4.10-2 [2,145 kB]
Fetched 5,267 kB in 0s (15.0 MB/s)
Selecting previously unselected package libdpkg-perl.
(Reading database ... 38475 files and directories currently installed.)
Preparing to unpack .../0-libdpkg-perl_1.18.25_all.deb ...
Unpacking libdpkg-perl (1.18.25) ...
Selecting previously unselected package dpkg-dev.
Preparing to unpack .../1-dpkg-dev_1.18.25_all.deb ...
Unpacking dpkg-dev (1.18.25) ...
Selecting previously unselected package libfakeroot:amd64.
Preparing to unpack .../2-libfakeroot_1.21-3.1_amd64.deb ...
Unpacking libfakeroot:amd64 (1.21-3.1) ...
Selecting previously unselected package fakeroot.
Preparing to unpack .../3-fakeroot_1.21-3.1_amd64.deb ...
Unpacking fakeroot (1.21-3.1) ...
Selecting previously unselected package libalgorithm-diff-perl.
Preparing to unpack .../4-libalgorithm-diff-perl_1.19.03-1_all.deb ...
Unpacking libalgorithm-diff-perl (1.19.03-1) ...
Selecting previously unselected package libalgorithm-diff-xs-perl.
Preparing to unpack .../5-libalgorithm-diff-xs-perl_0.04-4+b2_amd64.deb ...Unpacking libalgorithm-diff-xs-perl (0.04-4+b2) ...
Selecting previously unselected package libalgorithm-merge-perl.
Preparing to unpack .../6-libalgorithm-merge-perl_0.08-3_all.deb ...
Unpacking libalgorithm-merge-perl (0.08-3) ...
Selecting previously unselected package libfile-fcntllock-perl.
Preparing to unpack .../7-libfile-fcntllock-perl_0.22-3+b2_amd64.deb ...
Unpacking libfile-fcntllock-perl (0.22-3+b2) ...
Selecting previously unselected package manpages-dev.
Preparing to unpack .../8-manpages-dev_4.10-2_all.deb ...
Unpacking manpages-dev (4.10-2) ...
Setting up libdpkg-perl (1.18.25) ...
Setting up libfile-fcntllock-perl (0.22-3+b2) ...
Setting up dpkg-dev (1.18.25) ...
Processing triggers for libc-bin (2.27-6) ...
Setting up libfakeroot:amd64 (1.21-3.1) ...
Setting up libalgorithm-diff-perl (1.19.03-1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up manpages-dev (4.10-2) ...
Setting up fakeroot (1.21-3.1) ...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libalgorithm-merge-perl (0.08-3) ...
Setting up libalgorithm-diff-xs-perl (0.04-4+b2) ...
Processing triggers for libc-bin (2.27-6) ...
[master 77f42a4] committing changes in /etc after apt run
13 files changed, 28 insertions(+)
create mode 120000 alternatives/faked.1.gz
create mode 120000 alternatives/faked.es.1.gz
create mode 120000 alternatives/faked.fr.1.gz
create mode 120000 alternatives/faked.sv.1.gz
create mode 120000 alternatives/fakeroot
create mode 120000 alternatives/fakeroot.1.gz
create mode 120000 alternatives/fakeroot.es.1.gz
create mode 120000 alternatives/fakeroot.fr.1.gz
create mode 120000 alternatives/fakeroot.sv.1.gz
create mode 100644 dpkg/shlibs.default
create mode 100644 dpkg/shlibs.override
create mode 100644 ld.so.conf.d/fakeroot-x86_64-linux-gnu.conf

sudo aptitude -f install build-essential
The following NEW packages will be installed:
build-essential g++{a} g++-6{a} libc-dev-bin{ab}
libc6-dev{ab} libstdc++-6-dev{a} linux-libc-dev{a}
0 packages upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 12.6 MB of archives. After unpacking 60.9 MB will be used.
The following packages have unmet dependencies:
libc6-dev : Depends: libc6 (= 2.24-11+deb9u4) but 2.27-6 is installed
libc-dev-bin : Depends: libc6 (< 2.25) but 2.27-6 is installed
The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) build-essential [Not Installed]
2) g++ [Not Installed]
3) g++-6 [Not Installed]
4) libc-dev-bin [Not Installed]
5) libc6-dev [Not Installed]
6) libstdc++-6-dev [Not Installed]



Accept this solution? [Y/n/q/?]
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.


apt install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you haverequested 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:
build-essential : Depends: libc6-dev but it is not going to be installed or
libc-dev
Depends: g++ (>= 4:6.3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

结果还是一样。

同时我升级到了 Debian v9.12。

apt --dry-run install libc6=2.24-11+deb9u4
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  glibc-doc locales
The following packages will be REMOVED:
  libc-bin locales sudo
The following packages will be DOWNGRADED:
  libc6
WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
  libc-bin
0 upgraded, 0 newly installed, 1 downgraded, 3 to remove and 0 not upgraded.
Remv locales [2.27-6]
Remv libc-bin [2.27-6]
Remv sudo [1.8.23-2]
Inst libc6 [2.27-6] (2.24-11+deb9u4 Debian:9.12/oldstable [amd64])
Conf libc6 (2.24-11+deb9u4 Debian:9.12/oldstable [amd64])

我可以试试吗apt --dry-run install libc6=2.24-11+deb9u4

我该如何修复未满足的依赖关系?

答案1

您的问题是,在某个时间点,您从包含较新 的源安装了一个软件包,并且安装了libc6的版本。现在您的软件包已损坏,因为该软件包的版本为,但 libc6 软件包位于。这可能是由于您提到的 buster 存储库。libc6libc6-dev2.24-11+deb9u42.27-6

这里最大的问题是,由于 buster 是 debian 版本,如果您在源代码中使用它的时间足够长,那么许多软件包可能已经安装到您的系统中。如果您真的只是为了安装 mc 而使用它,那么解决方案可能会更简单。

您可以执行以下操作。

将您的系统升级至 buster。这可能不是您的最佳解决方案,但如果您更换 Buster 的源代码,并执行 dist-upgrade,一切都会好起来。毕竟,Buster 是一个稳定的版本。不过,您可能还是要考虑一下,因为这是一个完整的系统升级,并且根据您系统安装的内容,这可能会破坏您提供的服务。

降级你的 libc6 包。这很可能会破坏您的系统,所以请小心。通常这样做是个坏主意,除非您知道自己在做什么。请阅读全文,不要盲目复制命令。

您可能还升级了其他软件包,因为我不知道 buster 源在您的计算机上活跃了多长时间。首先,您需要安装正确的libc6软件包,您需要哪个版本2.24-11+deb9u4(根据您的帖子中的输出)。因此您需要执行以下操作。

发出

apt --dry-run install libc6=2.24-11+deb9u4

命令。在命令输出中,您将看到类似以下内容:

WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
  e2fsprogs libext2fs2 (due to e2fsprogs) libc-bin

软件包列表可能很复杂,但是对于其中的每一个,您都需要使用 检查可用版本apt-cache policy。您需要版本号最大的、未本地安装的软件包。记录版本号并请求安装具有该确切版本号的软件包。您应该--dry-run在 apt 命令中添加开关,因为这些软件包可能会反过来破坏其他软件包(这种情况不太可能发生,但最好确保万无一失)。您可能会遇到,它在 Stretch 中不存在。您可以放心地忽略它,但如果遇到其他无法降级的软件包,您应该记录下来,以后查找。通常,让 来处理这些软件包的删除libext2fs2是安全的。apt

获得所有版本号后,将所有软件包提供给apt,请求您记录的版本号,这样您最终会得到一个很长的软件包列表,如下所示(您的列表可能会更长,具体取决于您从 Buster 存储库安装了多少个软件包):

 apt --dry-run install e2fslibs=1.43.4-2+deb9u1 \
    e2fsprogs=1.43.4-2+deb9u1\
    libc-bin=2.24-11+deb9u4 \
    libc6=2.24-11+deb9u4

如果您在输出中没有看到任何“必需软件包将被删除”消息,则可以安全地在不使用开关的情况下发出命令--dry-run,并且您的系统将不会有任何损坏的软件包。如果您确实看到了该消息,则还需要在命令中包含这些软件包。反复执行,直到命令不会尝试删除任何必需软件包。但请注意,一些软件包将被卸载,您可能需要在需要时手动重新安装它们(但此时,(重新)安装不应造成任何问题或损坏的软件包)。

这就是为什么在系统上使用不同版本的存储库是一个坏主意。

答案2

我遇到了类似的问题。我通过这样做解决了它:

开始之前,如果您没有 aptitude,您可以按照以下说明进行安装:能力文档

如果你已经拥有它,你可以继续。首先你需要运行:

sudo aptitude install g++

系统将会询问:接受此解决方案吗?[Y/n/q/?] 您必须选择“n”。

它会建议你降级软件包,并会询问:接受这个解决方案吗?[Y/n/q/?]这次选择“Y”。

它将降级软件包。完成后,你现在可以按如下方式安装 build-essential:

sudo aptitude -f install build-essential

系统将会询问:接受此解决方案吗?[Y/n/q/?] 您必须选择“Y”。

它将安装它。完成后,您可以运行此命令来检查它:

sudo aptitude search build-essential

如果你在结果中看到这一行:

i build-essential - build-essential 包的信息列表

这意味着安装成功,但如果您没有看到它,那么您必须寻找其他解决方案来解决它。

答案3

您可以尝试清除所有缓存数据并手动安装依赖项。然后尝试安装软件包build-essential

$ sudo apt-get clean
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install libc6-dev g++
$ sudo apt install build-essential

答案4

在 Ubuntu 20.04.03 上安装 rust 和 build-essentials 的清单:

rustup self uninstall
apt-get update
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe"
apt-get -u dist-upgrade
apt install aptitude 
sudo aptitude install libc6=2.31-0ubuntu9
sudo aptitude install build-essential
apt-get update
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
rustup toolchain install nightly --allow-downgrade --profile minimal --component clippy
rustup default stable
rustup update nightly
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly
sudo apt install -y cmake pkg-config libssl-dev git gcc build-essential clang libclang-dev
rustc --version
source $HOME/.cargo/env

未经我测试:快速安装:使用单个命令安装所有必需的依赖项。(请耐心等待,这可能需要 30 分钟)

curl https://getsubstrate.io -sSf | bash -s -- --fast

最后一步测试:

https://doc.rust-lang.org/cargo/getting-started/first-steps.html

相关内容