Linux

Debian 9.12 中的 libc6 依賴項不匹配

  • February 28, 2020

我在 Debian 9.12 中遇到了以下 libc6 依賴問題。

sudo apt install libc6-dev

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.

我該如何解決?

EDIT1:apt策略libc6

libc6:
 Installed: 2.27-6
 Candidate: 2.27-6
 Version table:
*** 2.27-6 100
       100 /var/lib/dpkg/status
    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

編輯2:

apt install libc6/stretch libc6-dev/stretch libc-dev-bin/stretch
Reading package lists... Done
Building dependency tree
Reading state information... Done
Selected version '2.24-11+deb9u4' (Debian:9.12/oldstable [amd64]) for 'libc6'
Selected version '2.24-11+deb9u4' (Debian:9.12/oldstable [amd64]) for 'libc6-dev'
Selected version '2.24-11+deb9u4' (Debian:9.12/oldstable [amd64]) for 'libc-dev-bin'
The following additional packages will be installed:
linux-libc-dev
Suggested packages:
glibc-doc locales
The following packages will be REMOVED:
libc-bin locales sudo
The following NEW packages will be installed:
libc-dev-bin libc6-dev linux-libc-dev
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, 3 newly installed, 1 downgraded, 3 to remove and 0 not upgraded.
Need to get 6,797 kB of archives.
After this operation, 1,437 kB disk space will be freed.
You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'
?]

您將系統配置為一次使用來自多個發行版的軟體包(所謂的 Frankenstein-Debian),因此依賴性錯誤是正常的。cat /etc/apt/sources.list{,.d/*.list}bash中執行以列出所有源。

您的libc6 (version 2.27-6) 卡在了stretch (version 2.24-11+deb9u4) 和buster (version 2.28-10) 之間。我的猜測是你從buster中提取了一些包,而它仍然是測試發行版。解決這個問題最簡單的方法是:

  1. 在您的 APT 來源中找到對testingbuster的引用。如果你發現類似的東西:
deb http://deb.debian.org/debian testing main non-free contrib

將其替換為:

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

因為buster不再是測試分佈(靶心是)。 2. 更新軟體包列表:

apt update
  1. 將您的libc6升級到buster的版本:
apt install libc6/buster libc6-dev/buster libc-dev-bin/buster
  1. 考慮在不久的將來升級到 Debian 10以擁有來自同一發行版的所有軟體包。

**編輯:**似乎您的版本高於 Stretch 的軟體包很少,因此您可以降級它們:

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

並從 APT 來源中刪除buster和 company。

引用自:https://serverfault.com/questions/1004890