16

Environment?

  • Windows Subsystem for Linux.
  • Ubuntu 18.04.2 LTS
  • apt 1.6.11 (amd64)

What's wrong?

apt upgrade and apt autoremove not working. apt upgrade gives the following message

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  gir1.2-gtk-3.0 gtk-update-icon-cache libegl-mesa0 libgbm1 libgl1-mesa-dev libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa
  libglx-mesa0 libgtk-3-0 libgtk-3-bin libgtk-3-common libmspack0 linux-libc-dev mesa-common-dev
15 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/12.4 MB of archives.
After this operation, 4096 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up libc-bin (2.27-3ubuntu1) ...
Aborted (core dumped)
/sbin/ldconfig.real: Can't stat /usr/local/lib/x86_64-linux-gnu: No such file or directory
/sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
/usr/lib/x86_64-linux-gnu/libfakeroot:
        libfakeroot-0.so -> libfakeroot-tcp.so
/usr/local/lib:
/lib/x86_64-linux-gnu:
Aborted (core dumped)
dpkg: error processing package libc-bin (--configure):
 installed libc-bin package post-installation script subprocess returned error exit status 134
Errors were encountered while processing:
 libc-bin
E: Sub-process /usr/bin/dpkg returned an error code (1)

apt autoremove gives the following message

$ sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up libc-bin (2.27-3ubuntu1) ...
Aborted (core dumped)
/sbin/ldconfig.real: Can't stat /usr/local/lib/x86_64-linux-gnu: No such file or directory
/sbin/ldconfig.real: Path `/lib/x86_64-linux-gnu' given more than once
/sbin/ldconfig.real: Path `/usr/lib/x86_64-linux-gnu' given more than once
/usr/lib/x86_64-linux-gnu/libfakeroot:
        libfakeroot-0.so -> libfakeroot-tcp.so
/usr/local/lib:
/lib/x86_64-linux-gnu:
Aborted (core dumped)
dpkg: error processing package libc-bin (--configure):
 installed libc-bin package post-installation script subprocess returned error exit status 134
Errors were encountered while processing:
 libc-bin
E: Sub-process /usr/bin/dpkg returned an error code (1)

apt update and apt autoclean seem to be working correctly.

Reproduce?

I have no idea what caused the error... Also, I do not think I have done any dangerous operation to non-user files recently. I have googled the error messages I got, but fruitless. Anyone any idea?

3

4 Answers 4

15

Interestingly enough, when I tried what Eric Gazoni did when his slapd failed, of course dpkg didn't want me to forcibly remove vital organs of Ubuntu ;) ... But after stubbornly executing through his instructions, replacing slapd by libc-bin, and afterwards moving /tmp/libc-bin.* back to /var/lib/dpkg/info/, it repaired itself!

So, essentially this did the trick, although it is possible that not every command is necessary:

sudo mv /var/lib/dpkg/info/libc-bin.* /tmp/
sudo dpkg --remove --force-remove-reinstreq libc-bin
sudo dpkg --purge libc-bin
sudo apt install --reinstall libc-bin
sudo mv /tmp/libc-bin.* /var/lib/dpkg/info/
3
  • 8
    Just sudo apt install libc-bin did the trick - problem solved. Thanks! P.S. Removing the package didn't work - for each I got an error "this is an essential package; it should not be removed".
    – knee-cola
    Apr 22, 2020 at 7:00
  • 2
    I was able to follow the first 4 steps posted by MrExquisite to solve this. sudo mv /var/lib/dpkg/info/libc-bin.* /tmp/ sudo dpkg --remove --force-remove-reinstreq libc-bin sudo dpkg --purge libc-bin sudo apt install libc-bin I am running 18.04LTS on WSL2 and was getting an error doing my usual apt-get upgrade. Thank you sir! Oct 27, 2020 at 13:34
  • 1
    I had to use --force-depends instead of --force-remove-reinstreq, but this worked for me for a similar problem for mime-support - thank you!
    – scubbo
    Apr 8, 2021 at 0:28
10

A slightly less invasive fix:

for PROBDIR in "" "/usr" "/usr/local"; do find "${PROBDIR}/lib/x86_64-linux-gnu" -type f -ls; done;

Source: https://github.com/microsoft/WSL/issues/4760

4
  • Thanks so much, none of the other solutions worked, but this did.
    – Ben
    May 11, 2022 at 14:40
  • This command simply finds files and makes no changes. It is impossible for it to fix anything.
    – Dan Locks
    Sep 6, 2022 at 20:04
  • @DanLocks It's been a while since I tried this; I know it's not supposed to make any changes, but (based on the Github discussion), it seems like the filesystem ends up in a weird state which is fixed by accessing file metadata Nov 1, 2022 at 3:53
  • This actually worked, I can't believe it.
    – SomeDude
    Aug 10, 2023 at 7:44
5

This worked for me on WSL Ubuntu 20.04 to fix a coredump

for PROBDIR in "" "/usr" "/usr/local"; do find "${PROBDIR}/lib/x86_64-linux-gnu" -type f -ls; done;
sudo apt install libc-bin -y
sudo mv /var/lib/dpkg/info/libc-bin.* /tmp/
sudo apt install libc-bin -y
1
  • This fixed it for me! Tried everything else. Thanks
    – SevvyP
    Jan 16 at 2:26
3

Nothing else worked! Finally I tried his steps and voila! Back on track again

How to get software updates working in 16.04? It broke after a failed upgrade to 18.04

apt-get download libc-bin
sudo dpkg -x libc-bin*.deb /
sudo apt-get install --reinstall ./libc-bin*.deb
2
  • 2
    The other answers didn't work for me, but this did the job. I'm using a Debian WSL
    – Zciurus
    Apr 20, 2022 at 20:47
  • Only this worked for me with WSL Ubuntu 23.04 lunar.
    – pbies
    Jan 8 at 4:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .