Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am currently unable to install any packages. I receive the following error:

 dpkg: unrecoverable fatal error, aborting:
 too-long line or missing newline in `/var/lib/dpkg/diversions

I have tried various approaches:

sudo dpkg --configure -a   
sudo apt-get clean
sudo dpkg-divert --list 
sudo apt-get check  
sudo apt-get install -f

etc. but all to no avail. Either the output was apparently normal or the error above was thrown.

I'm stumped as to how to proceed and would appreciate any assistance. If any further info is required just ask.


Thanks for the reply. I followed the suggestions and am now getting a different error:

(Reading database ... 50%dpkg: unrecoverable fatal error, aborting: files list file for package 'libksane0' is missing final newline E: Sub-process /usr/bin/dpkg returned an error code (2)

Here is the link for the current diversions: http://paste.ubuntu.com/823500/ and the old broken one: http://paste.ubuntu.com/823502/

I tried to reinstall libksane0 but the same error occurred.

share|improve this question
    
It might help if you uploaded your /var/lib/dpkg/diversions to paste.ubuntu.com so we could take a look. –  Marius Gedminas Jan 31 '12 at 0:37
    
Actually, upload /var/lib/dpkg/diversions-old too; the differences between the two might be illuminating. –  Marius Gedminas Jan 31 '12 at 0:43
add comment

3 Answers 3

First, back up /var/lib/dpkg/diversions and /var/lib/dpkg/diversions-old, just in case.

Next, try copying /var/lib/dpkg/diversions-old on top of /var/lib/dpkg/diversions:

cd /var/lib/dpkg
mv diversions diversions.broken
cp diversions-old diversions

Now dpkg should be able to work again, but it's possible that its diversions database is incomplete. Reinstalling (apt-get install --reinstall packagename) the affected packages might be a good way to restore that; question is: how can you identify which packages were affected? Comparing the contents of diversions.broken and diversions-old (diff -u diversions-old diversions.broken) is one way; looking in /var/log/dpkg.log for a list of recently updated packages and reinstalling them just in case is another. It is also possible that nothing bad will happen from you having a slightly out-of-date diversions database; it all depends on what exactly is in those files.

share|improve this answer
add comment

This python script helped me:

http://ubuntuforums.org/showthread.php?t=1319791

share|improve this answer
1  
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  Aditya Jan 16 '13 at 8:22
add comment

I know this is really late, but other people might find this still useful. The same error message with a different file popped up on Kali (Debian-Variant) and the best solution I found was copying the erroneous file from a still working copy of Kali. Problem solved.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.