Unmet dependencies. Libc6 The package system is broken

I had similar issue on freshly installed Ubuntu 20.04.2 desktop 64bit, the difference is that libc6 ...9.3 was installed but my packages (g++ build-essential etc) could not be installed beceause libc6-dev could not be installed because it required libc6 ...9.2 which was older then the one installed

 libc6-dev : Depends: libc6 (= 2.31-0ubuntu9.2) but 2.31-0ubuntu9.3 is to be installed

So I just downgraded libc6 (and libc-bin too, because it seems very related to me) to version 2.31-0ubuntu9.2 this way:

sudo apt install libc6=2.31-0ubuntu9.2 libc-bin=2.31-0ubuntu9.2

Now my packages could install :) so it seems to work, let's see if we don't have much problems - but I guess not because this is a tiny change in libc (on the other side libc is very important)

BUT I DON'T KNOW WHAT WILL HAPPEN IN THE FUTURE:

  • Will it in future updates hold this package fixed to still old version?
  • Does anyone know how to unfix this version?
  • Even if I could somehow unfix it from this version, then will ubuntu have this issue in the future?
  • Does anyone know if it is some bug in Ubuntu packaging repository? I repeat: this was on a totally fresh Ubuntu 20.04 desktop

Some other places to look for inspiration:

  • https://serverfault.com/a/993629/445123
  • https://serverfault.com/a/1005063/445123

I would like to add to the answer of Tomeg, that downgrading with aptitude helped me to keep my packages depending on libc6 installed. When downgrading with:

sudo apt install libc6=2.31-0ubuntu9.

apt would also uninstall all my packages depending on libc6.

The following packages will be DOWNGRADED:
  libc6
0 upgraded, 0 newly installed, 1 downgraded, 206 to remove and 0 not upgraded.

As I described here this did help since aptitude offered me different options:

 sudo aptitude install libc6=2.31-0ubuntu9.2

I had to decline the first two options (2x n) and then the third was to solely downgrade (y) without uninstalling other packages.