fail to upgrade libc6

Asked by lan1967

Hello, dear Ubuntu users!
I stumbled across a bug.
I am using Ubuntu 13.10 3.11.0-8-generic
and got problems with recent update of libc6.
Removing aforementioned '/lib/x86_64-linux-gnu/ld-2.17.so' ruins the system.
It refuses to recognize everything in the terminal including sudo and apt-get after that.
So I have to put it back.
What to do now if I can't this issue prevents me updating the system.
Thank you for your attention
 sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  libc6
Suggested packages:
  glibc-doc
The following packages will be upgraded:
  libc6
1 upgraded, 0 newly installed, 0 to remove and 80 not upgraded.
2 not fully installed or removed.
Need to get 0 B/4 730 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
Preconfiguring packages ...
(Reading database ... 381870 files and directories currently installed.)
Preparing to replace libc6:amd64 2.17-91ubuntu1 (using .../libc6_2.17-93ubuntu1_amd64.deb) ...

A copy of the C library was found in an unexpected directory:
  '/lib/x86_64-linux-gnu/ld-2.17.so'
It is not safe to upgrade the C library in this situation;
please remove that copy of the C library or get it out of
'/lib/x86_64-linux-gnu' and try again.

dpkg: error processing /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
David Pires
Solved:
Last query:
Last reply:
Revision history for this message
David Pires (slickymaster) said :
#1

See if this can somehow help you: http://shearer.org/Debugging_Dpkg_Problems
 And please do keep us inform on your progress

Revision history for this message
lan1967 (lan1967) said :
#2

sudo dpkg --debug=3773 -i /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
D000010: ensure_pathname_nonexisting '/var/lib/dpkg/tmp.ci'
(Reading database ... 381870 files and directories currently installed.)
Preparing to replace libc6:amd64 2.17-91ubuntu1 (using .../libc6_2.17-93ubuntu1_amd64.deb) ...
D000200: process_archive conffile '/etc/ld.so.conf.d/x86_64-linux-gnu.conf' in package libc6:amd64 - conff ?
D000020: process_archive conffile '/etc/ld.so.conf.d/x86_64-linux-gnu.conf' package=libc6:amd64 same hash=593ad12389ab2b6f952e7ede67b8fbbf
D000200: oldconffsetflags '/etc/ld.so.conf.d/x86_64-linux-gnu.conf' namenode 0x6f1a480 flags 5
D000001: process_archive oldversionstatus=broken due to failed removal or installation
D000002: fork/exec /var/lib/dpkg/tmp.ci/preinst ( upgrade 2.17-91ubuntu1 )

A copy of the C library was found in an unexpected directory:
  '/lib/x86_64-linux-gnu/ld-2.17.so'
It is not safe to upgrade the C library in this situation;
please remove that copy of the C library or get it out of
'/lib/x86_64-linux-gnu' and try again.

dpkg: error processing /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb (--install):
 subprocess new pre-installation script returned error exit status 1
D000002: fork/exec /var/lib/dpkg/tmp.ci/postrm ( abort-upgrade 2.17-91ubuntu1 )
D000010: ensure_pathname_nonexisting '/var/lib/dpkg/tmp.ci'
D000010: ensure_pathname_nonexisting running rm -rf '/var/lib/dpkg/tmp.ci'
D000010: ensure_pathname_nonexisting '/var/lib/dpkg/reassemble.deb'
Errors were encountered while processing:
 /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb

Revision history for this message
lan1967 (lan1967) said :
#3

sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 libc6 : Breaks: libc6:i386 (!= 2.17-91ubuntu1) but 2.17-93ubuntu1 is installed
 libc6:i386 : Breaks: libc6 (!= 2.17-93ubuntu1) but 2.17-91ubuntu1 is installed
 libc6-dev : Depends: libc6 (= 2.17-93ubuntu1) but 2.17-91ubuntu1 is installed
 libc6-i386 : Depends: libc6 (= 2.17-93ubuntu1) but 2.17-91ubuntu1 is installed
 libc6-pic : Depends: libc6 (= 2.17-93ubuntu1) but 2.17-91ubuntu1 is installed
 libc6-x32 : Depends: libc6 (= 2.17-93ubuntu1) but 2.17-91ubuntu1 is installed
E: Unmet dependencies. Try using -f.

Revision history for this message
lan1967 (lan1967) said :
#4

I don't know how to remove safely the problem package.

Revision history for this message
lan1967 (lan1967) said :
#5

root@rootkit:/home/rootkit# mkdir /usr/lib/tmp
root@rootkit:/home/rootkit# mv /lib/x86_64-linux-gnu/ld-2.17.so /usr/lib/tmp
root@rootkit:/home/rootkit# dpkg -i /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
(Reading database ... 381870 files and directories currently installed.)
Preparing to replace libc6:amd64 2.17-91ubuntu1 (using .../libc6_2.17-93ubuntu1_amd64.deb) ...

A copy of the C library was found in an unexpected directory:
  '/lib/x86_64-linux-gnu/libc-2.17.so'
It is not safe to upgrade the C library in this situation;
please remove that copy of the C library or get it out of
'/lib/x86_64-linux-gnu' and try again.

dpkg: error processing /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb (--install):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
root@rootkit:/home/rootkit# mv /lib/x86_64-linux-gnu/libc-2.17.so /usr/lib/tmp
root@rootkit:/home/rootkit# dpkg -i /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
(Reading database ... 381870 files and directories currently installed.)
Preparing to replace libc6:amd64 2.17-91ubuntu1 (using .../libc6_2.17-93ubuntu1_amd64.deb) ...

A copy of the C library was found in an unexpected directory:
  '/lib/x86_64-linux-gnu/libdl-2.17.so'
It is not safe to upgrade the C library in this situation;
please remove that copy of the C library or get it out of
'/lib/x86_64-linux-gnu' and try again.

dpkg: error processing /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb (--install):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
root@rootkit:/home/rootkit# mv /lib/x86_64-linux-gnu/libdl-2.17.so /usr/lib/tmp
root@rootkit:/home/rootkit# dpkg -i /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
(Reading database ... 381870 files and directories currently installed.)
Preparing to replace libc6:amd64 2.17-91ubuntu1 (using .../libc6_2.17-93ubuntu1_amd64.deb) ...

A copy of the C library was found in an unexpected directory:
  '/lib/x86_64-linux-gnu/libm-2.17.so'
It is not safe to upgrade the C library in this situation;
please remove that copy of the C library or get it out of
'/lib/x86_64-linux-gnu' and try again.

dpkg: error processing /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb (--install):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
root@rootkit:/home/rootkit# mv /lib/x86_64-linux-gnu/libm-2.17.so /usr/lib/tmp
root@rootkit:/home/rootkit# dpkg -i /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
(Reading database ... 381870 files and directories currently installed.)
Preparing to replace libc6:amd64 2.17-91ubuntu1 (using .../libc6_2.17-93ubuntu1_amd64.deb) ...

A copy of the C library was found in an unexpected directory:
  '/lib/x86_64-linux-gnu/libpthread-2.17.so'
It is not safe to upgrade the C library in this situation;
please remove that copy of the C library or get it out of
'/lib/x86_64-linux-gnu' and try again.

dpkg: error processing /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb (--install):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
root@rootkit:/home/rootkit# mv /lib/x86_64-linux-gnu/libpthread-2.17.so /usr/lib/tmp
root@rootkit:/home/rootkit# dpkg -i /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
(Reading database ... 381870 files and directories currently installed.)
Preparing to replace libc6:amd64 2.17-91ubuntu1 (using .../libc6_2.17-93ubuntu1_amd64.deb) ...

A copy of the C library was found in an unexpected directory:
  '/lib/x86_64-linux-gnu/librt-2.17.so'
It is not safe to upgrade the C library in this situation;
please remove that copy of the C library or get it out of
'/lib/x86_64-linux-gnu' and try again.

dpkg: error processing /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb (--install):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
root@rootkit:/home/rootkit# mv /lib/x86_64-linux-gnu/librt-2.17.so /usr/lib/tmp
root@rootkit:/home/rootkit# dpkg -i /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
(Reading database ... 381870 files and directories currently installed.)
Preparing to replace libc6:amd64 2.17-91ubuntu1 (using .../libc6_2.17-93ubuntu1_amd64.deb) ...

A copy of the C library was found in an unexpected directory:
  '/lib/libc-2.17.so'
It is not safe to upgrade the C library in this situation;
please remove that copy of the C library or get it out of
'/lib' and try again.

dpkg: error processing /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb (--install):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
root@rootkit:/home/rootkit# mv /lib/libc-2.17.so /usr/lib/tmp
root@rootkit:/home/rootkit# dpkg -i /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
(Reading database ... 381870 files and directories currently installed.)
Preparing to replace libc6:amd64 2.17-91ubuntu1 (using .../libc6_2.17-93ubuntu1_amd64.deb) ...

A copy of the C library was found in an unexpected directory:
  '/lib64/libc-2.17.so'
It is not safe to upgrade the C library in this situation;
please remove that copy of the C library or get it out of
'/lib64' and try again.

dpkg: error processing /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb (--install):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
root@rootkit:/home/rootkit# mv /lib64/libc-2.17.so /usr/lib/tmp
root@rootkit:/home/rootkit# dpkg -i /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
dpkg: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
root@rootkit:/home/rootkit# dpkg -i /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
dpkg: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
root@rootkit:/home/rootkit# mv /usr/lib/tmp/lib
libc-2.17.so libm-2.17.so librt-2.17.so
libdl-2.17.so libpthread-2.17.so
root@rootkit:/home/rootkit# mv /usr/lib/tmp/libc-2.17.so /lib64
mv: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory

Revision history for this message
lan1967 (lan1967) said :
#6

Trying to move problem files to temporary folder gave not much.

Revision history for this message
lan1967 (lan1967) said :
#7

Now I have to boot from LiveCD to put the files back.

Revision history for this message
lan1967 (lan1967) said :
#8

May be I need manually put files from deb package.

Revision history for this message
David Pires (slickymaster) said :
#9

I'm sorry that solution didn't provide much help with your situation. Nevertheless it won't hurt if you take a look at this other two distinct approaches on the same issue.

Please refer to:
http://knoppix.net/forum/showthread.php?29465-dpkg-error-upgr-libc6-A-copy-of-the-C-library-was-found-in-an-unexpected-directory&p=124943#post124943

and

http://mythopoeic.org/ubuntu-libc/

Please tells us how it went.

Revision history for this message
lan1967 (lan1967) said :
#10

Seemingly I found solution from here:
http://blog.i-al.net/2013/03/a-copy-of-the-c-library-was-found-in-an-unexpected-directory/

I used livecd and mount --bind

Then
chroot /mnt
cd /lib/x86_64-linux-gnu
cp libc-2.17.so libdl-2.17.so libm-2.17.so libpthread-2.17.so librt-2.17.so /root
LD_PRELOAD=/root/libc-2.17.so:/root/libdl-2.17.so:/root/libm-2.17.so:/root/libpthread-2.17.so:/root/librt-2.17.so bash
mv libc-2.17.so libdl-2.17.so libm-2.17.so libpthread-2.17.so librt-2.17.so /root
cd /lib64
mv libc-2.17.so libdl-2.17.so libm-2.17.so libpthread-2.17.so librt-2.17.so /root

apt-get -f dist-upgrade

Revision history for this message
lan1967 (lan1967) said :
#11

Now I have:
dpkg -l libc6
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii libc6:amd64 2.17-93ubunt amd64 Embedded GNU C Library: Shared li
ii libc6:i386 2.17-93ubunt i386 Embedded GNU C Library: Shared li

Revision history for this message
lan1967 (lan1967) said :
#12

According to the original inventor:
"...How it works:

Apt/dpkg was failing because it was finding the files in a place it didn’t like them, but simply removing them breaks things. By moving them to /root and then using a variable to tell bash where to find them, things worked while the upgrade happened and the upgrade was happy not seeing the files in /lib/x86_64-linux-gnu. Which also makes me happy!"
The only difference is I had to copy undesirable libraries then to move them to /root folder . Otherwise I got Error messages:
ERROR: ld.so: object '/root/libc-2.17.so' from LD_PRELOAD cannot be preloaded: ignored.
Also for some reason similar files in /lib64 folder were also not welcome.

Revision history for this message
lan1967 (lan1967) said :
#13

Force install
dpkg -i --force-all /var/cache/apt/archives/libc6_2.17-93ubuntu1_amd64.deb
did not help .

Revision history for this message
Best David Pires (slickymaster) said :
#14

The solution is in fact very similar to the one in the first link I provided you on post #9, which consists in the installation of the libc6 package inside a chroot jail.

Anyway, I'm glad you got it fixed. Please use the 'This Solved My Problem' button located at the bottom of the answer, for future-help-others with same problem.

Revision history for this message
lan1967 (lan1967) said :
#15

Probably it has sense it unset LD_PRELOAD after upgrade.

unset LD_PRELOAD

Revision history for this message
lan1967 (lan1967) said :
#16

Thanks David Pires, that solved my question.

Revision history for this message
lan1967 (lan1967) said :
#17

It was similar but simply moving libc6 files only broke apt-get and dpkg without LD_PRELOAD.
The method is not evident and required some tricks and qualification.

Revision history for this message
lan1967 (lan1967) said :
#18

It's a mad dance with a tambourine.