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.

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

答案1

最后我在另一个论坛上得到了帮助: https://serverfault.com/a/1004951/302842

这是降级有问题的软件包的解决方案:

apt install libc6/stretch libc6-dev/stretch libc-dev-bin/stretch libc-bin/stretch locales/stretch sudo/stretch

降级成功!

答案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 包的信息列表

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

相关内容