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
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 --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 命令,因為這些軟體包可能會依次破壞其他軟體包(這不太可能,但最好確定一下)。您可能會遇到libext2fs2
Stretch 中不存在的 。你可以放心地忽略那個,但是如果你遇到其他無法降級的包,你應該記錄它們,然後再查找它們。通常,讓apt
處理這些刪除是安全的。獲得所有版本號後,將所有包提供給
apt
,請求您記錄的版本號,因此您將得到一個長長的(ish)包列表,如下所示(您的列表可能更長,具體取決於您有多少包從 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
開關的情況下安全地發出命令,並且您的系統不會有任何損壞的軟體包。如果確實看到該消息,則還需要在命令中包含這些包。迭代直到該命令不嘗試刪除任何必要的包。但是請注意,將解除安裝一些軟體包,如果需要,您可能需要手動重新安裝它們(但此時,(重新)安裝不應造成任何問題或損壞的軟體包)。這就是為什麼在系統上使用不同版本的儲存庫是一個壞主意。
我有一個類似的問題。我通過這樣做來解決它:
在開始之前,如果您沒有 aptitude,可以按照以下說明進行安裝: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 - 建構基本包的資訊列表
這意味著安裝成功,但是如果您沒有看到它,那麼您需要尋找其他解決方案才能解決它。