10

I am unable to use the apt-get command to install any packages on my pi.

I started trying to install python-pip using

sudo apt-get install python-pip

which results in the error

dpkg: unrecoverable fatal error, aborting:
files list file for package 'libc6:armhf' is missing final newline
E: Sub-process /usr/bin/dpkg returned an error code (2)

I tried some other packages, but none worked. They all result in the same error.

After attempting several fixes from Google, I have been unable to resolve the issue.

1
  • I have a similar problem. when i install anything i get files list file for package `fcmp' contains empty filename And i tried to reinstall libc6 but get this message along with dpkg error code 2. Any one, help?
    – user10171
    Commented Oct 22, 2013 at 22:34

3 Answers 3

10

Delete the file /var/lib/dpkg/info/libc.list (or the closest to that name), and then run sudo apt-get install libc --reinstall

4
  • I renamed libc6:armhf.list and ran the reinstall. This was the result : pastebin.com/mr224BqB I don't recall ever trying to install C in a different location.
    – MrZander
    Commented Dec 31, 2012 at 4:40
  • I also have /lib/arm-linux-gnueabihf/libc-2.13.so in my setup. Don't delete it as this thread says that no commands will work after that. Commented Dec 31, 2012 at 16:37
  • Well, I guess this solution half worked. I get a warning-error thing but the packages install.
    – MrZander
    Commented Jan 2, 2013 at 18:07
  • A silent hero right there. @MrZander this should be the accepted answer. I just had the same problem with the package raspberrypi-bootloader, removed /var/lib/dpkg/info/raspberrypi-bootloader.list and reinstalled, error went away.
    – php_nub_qq
    Commented Apr 13, 2020 at 17:04
2

I got hit by that too on first install: dd'ed the firmware, 1st boot, apt-get update doesn't work. Conclusion: write errors on the SD card. In my case, my card was old, so I just bought another. Note that write errors can also occur with bad power supply / bad micro-usb cable.

1
  • I am going to flag this one as accepted. I had some issues while flashing my SD card.
    – MrZander
    Commented Jan 2, 2013 at 18:08
1

A more generic answer for people sent here by Google

My issue was with the package libsoxr0:armhf but Google found this to be the most relevant question.

Why you should NOT downvote this answer

I hate that I have to do this, but I've been using SO/SE for over a decade and I know how negative people can be.

I teach children and adults to hack RaspberryPi, Arduino, ESP8266, etc. at multiple Maker Spaces. I'm putting this answer here for them and not for the OP that created this question in 2012

The problem

In my case I searched for my exact error message:

files list file for package 'libsoxr0:armhf' is missing final newline

The answers here would not have helped my if I would have done a blind copy/pasta, but luckily I have enough experience to cautiously use the info to resolve my issue. Read on to learn to the skills to do the same.

The solution

1st define variables so that future readers can copy/pasta

That future reader just might be yourself.

Documentation is a love letter that you write to your future self. - Damian Conway

# Put the name of your package here
pkg='libsoxr0:armhf'

Inspect the file and compare it to something similar

This will show you the content of your file without corrupting (which would only be a temporary until you close and reopen or possibly correct it with tset or reset) your tty ([incorrectly] aka: terminal, shell, bash, etc.)

# To exit the command `less` hit "q"
less /var/lib/dpkg/info/$pkg.list

You'll probably see some non-ascii garbage in there. Compare that to anything else.

less /var/lib/dpkg/info/init.list

In mine I have... (that last line is not IN the file, it's part of the UI of the less command)

/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/init
/usr/share/doc/init/changelog.gz
/usr/share/doc/init/copyright
/var/lib/dpkg/info/init.list (END)

Note: I chose init.list because it was the smallest file according to ls -lS /var/lib/dpkg/info/*.list, but it your original error had said for package 'init', you'd want to chose another file from the output of that ls command.

Eliminate the problem

Any time you read something on the internet that says "fix your problem by deleting this file/directory" you should instinctively translate that to "move it out of the way and take notes".

# start in your home directory
cd

# create a directory to keep your stuff organized
directory="HACK $(date)"
mkdir "$directory"
cd "$directory"

# remind yourself where you got this [possibly dumb] idea
url="https://raspberrypi.stackexchange.com/a/138679/8375"
echo "$url" >> FROM.url

# finally do the only thing you REALLY needed to do if the instructions you were following were perfect
sudo mv /var/lib/dpkg/info/$pkg.list ./
sudo apt install $pkg --reinstall

# compare the file you just moved the one that got recreated
less /var/lib/dpkg/info/$pkg.list

# write yourself a love letter
history >> HISTORY.txt

# lay it on thick
echo "I think you are awesome." >> README.txt
echo "I know I don't say it as often as you deserve to hear it." >> README.txt
echo "☮️❤️🌈🧘🏽🕉☸️☯️" >> README.txt

Artifacts

Now that everything is working, I can remove the directory I created to clean up. Here is one last peek before it goes away...

pi@openmediavault:~/HACK Sun Aug 14 10:23:51 CDT 2022 $ ls -la
total 32
drwxr-xr-x 2 pi users  4096 Aug 14 11:02 .
drwxr-xr-x 9 pi users  4096 Aug 14 10:47 ..
-rw-r--r-- 1 pi users   128 Aug 14 11:02 FROM.url
-rw-r--r-- 1 pi users 12748 Aug 14 11:02 HISTORY.txt
-rw-r--r-- 1 pi users   124 Aug 14 11:02 README.txt

Oh, who am I kidding? I can't throw that away. I'm just going archive it over on my OpenMediaVault JBOD. Oh wait, it's already there.

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