Debian – How to fix broken libxml2-dev dependency on Debian using apt

aptdebian

When I run sudo apt-get upgrade on my Debian Squeeze install, I get the following error:

You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 libxml2-dev : Depends: libxml2 (= 2.7.8.dfsg-2+squeeze3) but 2.7.8.dfsg-2+squeeze5 is installed
E: Unmet dependencies. Try using -f.

I'm not sure what "squeeze3" versus "squeeze5" means, but it is the only thing that differs in the libxml2 package.

When I try "sudo apt-get install -f", I get:

The following extra packages will be installed:
  libxml2-dev
The following packages will be upgraded:
  libxml2-dev
1 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
108 not fully installed or removed.
Need to get 0 B/830 kB of archives.
After this operation, 69.6 kB disk space will be freed.
Do you want to continue [Y/n]? Y
(Reading database ... 96842 files and directories currently installed.)
Preparing to replace libxml2-dev 2.7.8.dfsg-2+squeeze3 (using .../libxml2-dev_2.7.8.dfsg-2+squeeze5_amd64.deb) ...
Unpacking replacement libxml2-dev ...
dpkg: error processing /var/cache/apt/archives/libxml2-dev_2.7.8.dfsg-2+squeeze5_amd64.deb (--unpack):
 unable to install new version of `./usr/include/libxml2': No such file or directory
configured to not write apport reports
                                      dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libxml2-dev_2.7.8.dfsg-2+squeeze5_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

A similar error occurs with sudo apt-get upgrade -f.

My /etc/apt/sources.list is currently:

deb http://ftp.us.debian.org/debian/ squeeze main contrib non-free
deb http://ftp.debian.org/debian/ squeeze-updates main contrib non-free
deb http://security.debian.org/ squeeze/updates main contrib non-free

How do I go about fixing this? Thanks!

Best Answer

squeeze3 is the third patch release for squeeze, squeeze5 is the fifth. They're part of the version number. The versions for the library and the development files must match exactly, so it's normal that APT wants you to run apt-get install -f when your system has inconsistent versions.

What isn't normal is that the upgrade of libxml2-dev is failing. The message about not being able to read /usr/include/libxml2 is unusual. It seems to indicate that the installation has been damaged in some way. Check whether the directory still exists. If you moved or removed it at some point… don't do that, and re-create or move back the directory to recover. If the directory exists but you see something like

$ ls -ld /usr/include/libxml2
?????????? ??? ???????? ???????? 4096 ??? ?? ???? /usr/include/libxml2

then your filesystem is corrupted, or perhaps your RAM. First, check your RAM: this is the most common cause of filesystem corruption. Write as little as possible until you're sure about the RAM, as you may make the damage worse. How to take it from there depends on the nature and extent of the damage.

Related Question