22

My system runs inside WSL, I upgrade it at least every few days. I stuck with one package installation, and looking for a way to solve this:

$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libbind9-161 libdns-export1107 libdns1107 libdns1109 libirs161 libisc-export1104 libisc1104 libisc1105 libisccc161
  libisccfg163 liblwres161 liboauth0
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libc-bin
The following packages will be upgraded:
  libc-bin
1 upgraded, 0 newly installed, 0 to remove and 882 not upgraded.
6 not fully installed or removed.
Need to get 0 B/633 kB of archives.
After this operation, 8,192 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up libc6:amd64 (2.31-0ubuntu6) ...
Checking for services that may need to be restarted...
Checking init scripts...
Nothing to restart.
sleep: cannot read realtime clock: Invalid argument
dpkg: error processing package libc6:amd64 (--configure):
 installed libc6:amd64 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 libc6:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

What can I try next?

Adam Mierzwiak
  • 350
  • 2
  • 6
  • 18

3 Answers3

66

I ran into the same problem, and this procedure from this bug report fixed it:

Edit /var/lib/dpkg/info/libc6\:amd64.postinst

and comment out the line

# set -e

so $ apt-get -f install can continue.

Martijn
  • 13,225
  • 3
  • 48
  • 58
  • 1
    Thank you, it helped, finally I can transfer from testing to 20.04LTS – Adam Mierzwiak May 10 '20 at 05:18
  • 5
    @AdamMierzwiak Be careful, this merely disables "stop on errors" in that post-install script; Ubuntu fossal doesn't officially work in WSL1, so it's probably better to upgrade to WSL2 before. This might not be the only problem. – Martijn May 10 '20 at 07:40
  • Thank you for the warning, currently system is blocked on older Win10 than that supporting WSL2 by domain administrator – Adam Mierzwiak May 10 '20 at 10:57
  • 3
    If you cannot spot it, it is the second line! – George Ogden Jun 13 '20 at 20:06
  • 2
    You have saved me! – buycanna.io Jul 21 '20 at 06:22
  • 2
    Thank you. I am having to switch to WSL after my cygwin installation ballsed up, figured may as well make the switch now but ran into this issue quickly. Thank you for a simple and accurate solution. – Arthur Bowers Aug 19 '20 at 10:43
  • 1
    This solution I used also to transform from Ubuntu 20.04 to 20.10 testing. Same problem appears – Adam Mierzwiak Aug 24 '20 at 09:55
  • 1
    I faced with the problem with kali – Pranithan T. Aug 27 '20 at 04:44
  • 1
    Next time you cant find what youre looking for, use nano, Ctrl + W and type the keyword and enter. It will move the cursor where that keyword is. If it's not that one, press Ctrl + W again and just press enter (memorises your last input). I use this alot and it helps – LtMuffin Sep 05 '20 at 21:15
  • I have been trying to fix this for hours now, you just saved me. BTW after that I ran apt update and dist upgrade to wrap things up. – Ayyoub Jul 01 '21 at 22:33
  • this file not exist in my ubuntu 20.04.3 LTS – Mr Candido Nov 10 '22 at 13:49
14

You can use this sequence of commands (up to 3) to force a re-download of the partial files of the offending packages. Remaining steps are done to merge the new files with the old one, to avoid warnings and issues on non-offending packages that do not get downloaded in this attempt.

  1. sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_old
  2. sudo mkdir /var/lib/dpkg/info
  3. sudo apt-get update && sudo apt-get -f install
  4. sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info_old
  5. sudo rm -rf /var/lib/dpkg/info 
  6. sudo mv /var/lib/dpkg/info_old /var/lib/dpkg/info
Alessandro Lai
  • 2,254
  • 2
  • 24
  • 32
OdTu
  • 149
  • 3
  • ``` libkmod: ERROR ../libkmod/libkmod-module.c:1668 kmod_module_new_from_loaded: could not open /proc/modules: No such file or directory Error: could not get list of modules: No such file or directory setting xserver-xorg-legacy/xwrapper/allowed_users from configuration file Setting up libc6:amd64 (2.31-0ubuntu9) ... sleep: cannot read realtime clock: Invalid argument dpkg: error processing package libc6:amd64 (--configure): installed libc6:amd64 package post-installation script subprocess returned error exit status 1 Errors were encountered while processing: libc6:amd64 ``` – Adam Mierzwiak Apr 25 '20 at 15:23
  • What is the aim of steps 4 to 6? Seems like not visible effect from system standpoint or I miss something ? – Adam Mierzwiak May 10 '20 at 05:22
  • 2
    THanks @OdTu you saved my day .... I was having trouble installing libmysqlclient-dev and only this solution worked – virtuvious Jul 10 '20 at 23:29
  • 1
    In my case it did not solved the issue, but I see that some other people issues were covered. Thank you – Adam Mierzwiak Aug 20 '20 at 11:59
  • Steps 4-6 literally do nothing. Steps 1-3 didn't help me. – Hack-R Jul 31 '22 at 16:49
  • Solved an issue with borked docker configuration. Tx. – Max Robbertze Dec 13 '22 at 14:54
4

I ran into the same problem when upgrading Kali Linux inside WSL. I used these sequence of commands to fix the issue

  1. cd /tmp
  2. apt -y download libcrypt1
  3. dpkg-deb -x libcrypt1_1%3a4.4.27-1.1_amd64.deb .
  4. cp -av lib/x86_64-linux-gnu/* /lib/x86_64-linux-gnu/
  5. apt -y --fix-broken install
Cjay
  • 41
  • 5