使用 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
EDIT1:apt-cache 策略 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
EDIT2:
我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
吗?
如何修复未满足的依赖项?
您的问题是,在某个时间点,您从包含更新的源安装了一个包
libc6
,并且安装了该版本libc6
。现在你的包坏了,因为libc6-dev
包的版本是2.24-11+deb9u4
,但 libc6 包是2.27-6
. 这可能是因为您提到的 buster 存储库。这里最大的问题是,由于 buster 是 debian 版本,如果您在源代码中使用它的时间足够长,那么您的系统中可能已经安装了许多软件包。如果你真的只是为了安装mc,那么解决方案可能会更简单。
这是你可以做的。
将您的系统升级到破坏者。这对您来说可能不是一个好的解决方案,但是如果您将源代码替换为 buster,并进行 dist 升级,那么一切都会好起来的。毕竟,Buster 是一个稳定的版本。不过,您可能需要考虑一下,因为它是一个完整的系统升级,并且根据您的系统安装的内容,这可能会破坏您提供的服务。
降级你的 libc6 包。这很可能会破坏你的系统,所以要小心。通常这样做是个坏主意,除非您知道自己在做什么。请阅读全文,不要盲目复制命令。
您可能还升级了其他软件包,因为我不知道 buster 源在您的计算机上激活了多长时间。首先,您需要安装正确的
libc6
包,您需要版本2.24-11+deb9u4
(根据您帖子中的输出)。因此,您需要执行以下操作。发出
命令。在命令输出中,您将看到如下内容:
软件包列表可能很谨慎,但对于其中的每一个,您都需要使用
apt-cache policy
. 您需要具有最大版本号的那个,它不是本地安装的。记录版本号并请求具有该确切版本号的软件包进行安装。您应该将--dry-run
开关添加到 apt 命令,因为这些软件包可能会依次破坏其他软件包(这不太可能,但最好确定一下)。您可能会遇到libext2fs2
Stretch 中不存在的 。你可以放心地忽略那个,但是如果你遇到其他不能降级的包,你应该记录下来,以后再查。通常,让apt
处理这些删除是安全的。获得所有版本号后,将所有包提供给
apt
,请求您记录的版本号,因此您将得到一个长长的(ish)包列表,如下所示(您的列表可能更长,具体取决于您有多少包从 Buster 存储库安装):如果您在输出中没有看到任何“将删除基本软件包”消息,您可以在没有
--dry-run
开关的情况下安全地发出命令,并且您的系统不会有任何损坏的软件包。如果确实看到该消息,则还需要在命令中包含这些包。迭代直到该命令不尝试删除任何必要的包。但是请注意,将卸载一些软件包,如果需要,您可能需要手动重新安装它们(但此时,(重新)安装不应造成任何问题或损坏的软件包)。这就是为什么在系统上使用不同版本的存储库是一个坏主意。
我有一个类似的问题。我通过这样做来解决它:
在开始之前,如果您没有 aptitude,可以按照以下说明进行安装:aptitude 文档
如果你已经拥有它,你可以继续前进。首先你需要运行:
它会问这个:接受这个解决方案吗?[Y/n/q/?] 您必须选择“n”。
它会建议你降级包,它会问这个:接受这个解决方案吗?[Y/n/q/?]这次选择“Y”。
它将降级软件包。完成后,您现在可以通过执行以下操作安装 build-essential:
它会问这个:接受这个解决方案吗?[Y/n/q/?] 您必须选择“Y”。
它将安装它。完成后,您可以运行以下命令进行检查:
如果您在结果中看到这一行:
这意味着安装成功,但是如果您没有看到它,那么您需要寻找其他解决方案才能解决它。
您可以尝试清理所有缓存数据并手动安装依赖项。然后尝试安装包
build-essential
最后我在另一个论坛上得到了帮助: https ://serverfault.com/a/1004951/302842
这是降级有问题的软件包的解决方案:
降级成功!
在 Ubuntu 20.04.03 上安装 rust 和 build-essentials 的清单:
没有对我进行测试:快速安装:使用单个命令安装所有必需的依赖项。(请耐心等待,这可能需要 30 分钟)
最后一步测试:
https://doc.rust-lang.org/cargo/getting-started/first-steps.html