August 5, 2010

Solving Error "E: Sub-process /usr/bin/dpkg returned an error code (2)" In Ubuntu 10.04

I noticed that suddenly my Synaptic and apt-get weren't installing any package on my new Ubuntu 10.04. On looking at the details, I found the following error being flashed:

dpkg: unrecoverable fatal error, aborting:
statoverride statoverride unknown group gnokii
E: Sub-process /usr/bin/dpkg returned an error code (2)


I Googled and found the following two links:

1. http://ubuntuforums.org/showthread.php?t=508679

2. http://ubuntuforums.org/archive/index.php/t-329560.html

From the two links above, I knew I had to see or even edit my /var/lib/dpkg/statoverride file.

It contained:

root mlocate 2755 /usr/bin/mlocate
hplip root 755 /var/run/hplip
root gnokii 4750 /usr/sbin/mgnokiidev


I deleted the last line "root gnokii 4750 /usr/sbin/mgnokiidev". But it gave a similar error:

dpkg: unrecoverable fatal error, aborting:
statoverride file contains empty line
E: Sub-process /usr/bin/dpkg returned an error code (2)


This was shocking as the file isn't empty.

Then, I realized that my cursor was on an empty line. Doing a backspace and bringing it to the last non-empty line solved the problem, irrespective of the line "root gnokii 4750 /usr/sbin/mgnokiidev" being present in the file.

It wasn't a serious problem anyways.