I keep having an error installing / updating / basically doing anything that concerns packages. I am trying to get an I2C library going and I can't get sudo-apt-get install i2c-tools to work from a failing dpkg.

The error code I am getting is:

dpkg: unrecoverable fatal error, aborting:
files list for package 'libcap2:armf' is missing final newline
e: sub-process /user/bin/dpkg return an error code (2)

Whenever I try sudo apt-get remove libcap2:armf (or libcap2-bin) it begins, but when I select Y to complete it throws up a dpkg error for libcap2:armf... I can't remove it all the way because whatever it's doing is dependent on this?

Is there any way to recover from this? Otherwise I have to move my pi to a fresh OS and reconfigure it all (as I unfortunately did not take an established backup).


Based on this Ask Ubuntu answer, you could:

mkdir ~/dpkg-info
sudo mv /var/lib/dpkg/info/libcap2:armf.* ~/dpkg-info

This keeps a copy of the corrupted file(s) in ~/dpkg-info for whatever reason; if you don't want to bother with that use rm /var/lib/dpkg/info/libcap2:armf.* instead.


sudo dpkg --configure -a
sudo apt update
sudo apt upgrade

Hopefully whatever caused the problem did not have more widespread consequences.

  • Removing the initial issue has helped me get somewhere else, I am now able to get partially though upgrading and returning an error code 1. Once I removed libcap2:armhf, I had to remove 2 more entries for the same fault, then I was able to get to a different place. I am currently following the error up with (from sudo apt upgrade) Errors were encountered while processing: /var/cache/apt/archives/lib.... /var/cache/apt/archives/rpcbind... – Ricky Layman May 4 '18 at 19:59
  • It sounds like significant parts of the directory were corrupted. I'd guess because a lot of that stuff got laid down as part of the original image (?) much of it is physically contiguous on the SD card. By default fsck should be run at boot if the system was not shut down cleanly -- have you noticed this take extra time? I'd take the card out and run that on a separate (linux or otherwise posix ext fs capable) system, although at this point it may not say much since the damage and (probably) an attempt to fix it has already been done. – goldilocks May 5 '18 at 12:38
  • ...A clue would be if there is anything in the /lost+found directory. The lesson here is that you should keep a decent backup ;) raspberrypi.stackexchange.com/a/5492/5538 It is not hard once you get the hand of it. – goldilocks May 5 '18 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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