2

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!'
?]
klor
  • 304
  • 4
  • 8
  • 24
  • 1
    You already have this question on Unix Stackexchange: https://unix.stackexchange.com/questions/570133/libc6-dependency-mismatch-in-debian-9-12-stretch – Nasir Riley Feb 27 '20 at 23:33
  • 1
    and also on SU: https://superuser.com/questions/1528878/libc6-dependency-mismatch-in-debian-9-12-stretch – A.B Feb 28 '20 at 00:28

2 Answers2

6

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 (version 2.24-11+deb9u4) and buster (version 2.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:

  1. Find in your APT sources a reference to testing or buster. If you find something like:

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

    replace it with:

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

    since buster isn't the testing distribution any more (bullseye is).

  2. Update the list of packages:

    apt update
    
  3. Upgrade your libc6 to the version from buster:

    apt install libc6/buster libc6-dev/buster libc-dev-bin/buster
    
  4. 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:

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

and remove buster and company from APT sources.

Piotr P. Karwasz
  • 5,292
  • 2
  • 9
  • 20
  • Thanks for your answer! Downgrading libc6 isn't an option? Could be possible? – klor Feb 28 '20 at 23:21
  • Sure, you can downgrade it (just replace `/buster` with `/stretch`), but I believe you have packages on your system that forced the upgrade in the first place. You'll need to downgrade them too. – Piotr P. Karwasz Feb 28 '20 at 23:24
  • Added EDIT2 to OP. The downgrade wants to remove sudo, too. Would not cause any harm? May I continue the downgrade with yes? – klor Feb 28 '20 at 23:37
  • 2
    `apt install libc6/stretch libc6-dev/stretch libc-dev-bin/stretch libc-bin/stretch locales/stretch sudo/stretch` – Piotr P. Karwasz Feb 28 '20 at 23:39
  • 1
    Thank you very much! The downgrade went successful with the last command! I'm so happy now! – klor Feb 28 '20 at 23:48
  • If you include the last command into the answer, I will accept your answer as solution. – klor Feb 28 '20 at 23:48
  • But please keep the upgrade part of your answer, too. – klor Feb 28 '20 at 23:49
  • If you want a bounty, post this answer in my question. – Fel Jun 07 '20 at 01:43
0

I just now had this same issue moving from Debian Stretch to Sid 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 with systemctl reboot, or wsl -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 and libcrypt .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 run wsl -u root to enter the WSL container (in regular Debian, simply login as root user directly).

Inside WSL, create a folder for your .debs and use wget 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.deb

libcrypt1_4.4.28-2: http://ftp.us.debian.org/debian/pool/main/libx/libxcrypt/libcrypt1_4.4.28-2_amd64.deb

If you don't have wget, and obviously can't run apt in order to install it, you'll have to try curl -O $LINK, or download a binary distribution of either (Google for it).

Install libc first using dpkg:

# dpkg -i libc6_2.34-4_amd64.deb

Then install libcrypt:

# dpkg -i libcrypt1_4.4.18-4_amd64.deb

After a big OS infrastructure update like libc, exit WSL prompt and run wsl --terminate Debian from CMD prompt (or reboot machine if not WSL), then enter again with wsl -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 using apt update prior), and it should pull the rest of your system up to the new dependency plateau created by installing libc6 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 try apt dist-upgrade again.

Contrary to other instructions that say run apt upgrade before apt 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:

Preparing to unpack .../util-linux_2.38.1-1_amd64.deb ...
Unpacking util-linux (2.38.1-1) over (2.29.2-1+deb9u1) ...
dpkg: error processing archive /var/cache/apt/archives/util-linux_2.38.1-1_amd64.deb (--unpack):
 trying to overwrite '/bin/findmnt', which is also in package mount 2.29.2-1+deb9u1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/util-linux_2.38.1-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

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 of mount installed. To verify this was the case, I ran this little for loop, which checks upgradable packages for the two conflicting packages, respectively (the 2>/dev/null filters out that annoying WARNING: Cli interface blah blah message):

# for i in util-linux mount; do apt list --upgradable 2>/dev/null | grep $i; done

util-linux/unstable 2.38.1-1 amd64 [upgradable from: 2.29.2-1+deb9u1]
mount/unstable 2.38.1-1 amd64 [upgradable from: 2.29.2-1+deb9u1]

If your conflicting packages are different, just make $i reflect whichever packages you're checking your apt list --upgradable list for, such as for 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 in apt? The -o flag!

# apt -o Dpkg::Options::="--force-overwrite" --fix-broken install

spoiler You should probably add it to your dist-upgrade way back towards the beginning

# apt -o Dpkg::Options::="--force-overwrite" dist-upgrade

After all that, reboot your system (exit, C:\> wsl --terminate Debian) and enter it again, this time as your normal user, and see if stuff like sudo and passwd work now.

Can also check to see if the upgrade is reflected:

$ clear && uname -a; cat /etc/debian_version; cat -n /etc/os-release

Linux marmot 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 GNU/Linux
bookworm/sid

     1  PRETTY_NAME="Debian GNU/Linux bookworm/sid"
     2  NAME="Debian GNU/Linux"
     3  ID=debian
     4  HOME_URL="https://www.debian.org/"
     5  SUPPORT_URL="https://www.debian.org/support"
     6  BUG_REPORT_URL="https://bugs.debian.org/"

Install neofetch for more fun identification:

$ neofetch

       _,met$$$$$gg.          avery@marmot
    ,g$$$$$$$$$$$$$$$P.       ------------
  ,g$$P"     """Y$$.".        OS: Debian GNU/Linux bookworm/sid on Windows 10 x  ,$$P'              `$$$.     Kernel: 5.10.102.1-microsoft-standard-WSL2
',$$P       ,ggs.     `$$b:   Uptime: 22 hours, 27 mins
`d$$'     ,$P"'   .    $$$    Packages: 399 (dpkg)
 $$P      d$'     ,    $$P    Shell: bash 5.2.0
 $$:      $$.   -    ,d$$'    Terminal: Windows Terminal
 $$;      Y$b._   _,d$P'      CPU: Intel i5-6300U (4) @ 2.495GHz
 Y$$.    `.`"Y$$$$P"'         Memory: 71MiB / 6219MiB
  `Y$$
   `Y$$.
     `$$b.
       `Y$$b.
          `"Y$b._

Hope this helps someone.

AveryFreeman
  • 279
  • 1
  • 3
  • 12