I have the following libc6 dependency problem in Debian 9.12 stretch.
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.
How can I fix it?
EDIT1: apt policy 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
EDIT2:
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!'
?]
You configured your system to use packages from several distributions at once (a so-called Frankenstein-Debian), so dependency errors are normal. Run
cat /etc/apt/sources.list{,.d/*.list}
in bash to list all sources.Your libc6 (version
2.27-6
) is stuck somewhere between stretch (version2.24-11+deb9u4
) and buster (version2.28-10
). My guess is you pulled some packages from buster, while it was still the testing distribution. The easiest way to solve this problem is:Find in your APT sources a reference to testing or buster. If you find something like:
replace it with:
since buster isn't the testing distribution any more (bullseye is).
Update the list of packages:
Upgrade your libc6 to the version from buster:
Consider upgrading to Debian 10 in the near future to have all packages from the same distribution.
Edit: It seems you have few packages with a version higher than Stretch, so you can just downgrade them:
and remove buster and company from APT sources.
I just now had this same issue moving from Debian
Stretch
toSid
in WSL, which is why I landed on this question searching for a fix.Luckily, I was able to mitigate it fairly easily.
I apologize for responding with a WSL-specific answer to your question, but anything I mention here not specific to WSL should work on a regular Debian distro, too. The packages are the same on either platform.
For an example of a WSL-specific command translation, if you're not using WSL you could replace
wsl --terminate Debian
withsystemctl reboot
, orwsl -u root
with logging on as root to a freshly rebooted system.Here's how I solved the
libc
mismatch problem I was having:I downloaded
libc6
andlibcrypt
.deb
files from a local Debian mirror and installed them manually.If having trouble executing privileged commands, as I was due to the
libc
mismatch, you can runwsl -u root
to enter the WSL container (in regular Debian, simply login as root user directly).Inside WSL, create a folder for your
.deb
s and usewget
to get these two files (links are amd64 versions):libc6 2.34
: http://ftp.us.debian.org/debian/pool/main/g/glibc/libc6_2.34-4_amd64.deblibcrypt1_4.4.28-2
: http://ftp.us.debian.org/debian/pool/main/libx/libxcrypt/libcrypt1_4.4.28-2_amd64.debIf you don't have
wget
, and obviously can't runapt
in order to install it, you'll have to trycurl -O $LINK
, or download a binary distribution of either (Google for it).Install
libc
first usingdpkg
:Then install
libcrypt
:After a big OS infrastructure update like
libc
,exit
WSL prompt and runwsl --terminate Debian
from CMD prompt (or reboot machine if not WSL), then enter again withwsl -u root
(or login as root if not WSL). This is basically as close as you can get to a reboot in WSL.Then try running
apt dist-upgrade -y
(make sure you're refreshed your apt cache recently usingapt update
prior), and it should pull the rest of your system up to the new dependency plateau created by installinglibc6 2.34
for Bookworm.Basically, the idea here is to add as many packages as necessary before you can run an upgrade automatically. For me it took these two packages.
If you get a message to run
apt --fix-broken install
, try it, then tryapt dist-upgrade
again.Contrary to other instructions that say run
apt upgrade
beforeapt dist-upgrade
, that shouldn't be necessary now since you've already installed the big pieces. You can do it first if you want to, or run into problems, though.I also ran into this little snafu:
TL;DR if you just want the command, I put it under spoiler towards the end. If you'd rather follow the process of how I got there, read on ...
This could basically happen with any number of packages, in this case it's trying to install
util-linux
with an incompatible version ofmount
installed. To verify this was the case, I ran this littlefor
loop, which checks upgradable packages for the two conflicting packages, respectively (the2>/dev/null
filters out that annoyingWARNING: Cli interface blah blah
message):If your conflicting packages are different, just make
$i
reflect whichever packages you're checking yourapt list --upgradable
list for, such asfor systemd systemd-resolved; do ...
or whatever the package names may be.If they both show up in the list, bingo, they need to be installed using different timing, or in my case needed to overwrite one or the other while a conflicting version was installed.
dpkg
has a flag called--force-overwrite
, but how to run inapt
? The-o
flag!spoiler You should probably add it to your
dist-upgrade
way back towards the beginningAfter all that, reboot your system (
exit
,C:\> wsl --terminate Debian
) and enter it again, this time as your normal user, and see if stuff likesudo
andpasswd
work now.Can also check to see if the upgrade is reflected:
Install
neofetch
for more fun identification:Hope this helps someone.