Unable to install any packages due to unrecoverable fatal error /var/lib/dpkg/diversions
Solution 1:
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.
Solution 2:
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.