Fixing "Unable to parse package file /var/lib/apt/lists" Error in Ubuntu and Other Linux Distributions

Seeing "Unable to parse package file /var/lib/apt/lists" Error in Ubuntu Linux? Here's how to handle this common update error in Ubuntu-based distributions.
Warp Terminal

I have discussed a number of Ubuntu update errors in the past. If you use the command line to update Ubuntu, you might run into some ‘errors’.

Some of these ‘errors’ are basically built-in features to prevent unwarranted changes to your system. I am not going into those details in this quick tutorial.

In this quick tip, I’ll show you how to tackle the following error that you could encounter while updating your system or installing new software:

Reading package lists… Error!
E: Unable to parse package file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_InRelease
E: The package lists or status file could not be parsed or opened.

A similar error can be encountered in Debian:

E: Unable to parse package file /var/lib/apt/extended_states (1)

There is absolutely no need to panic even thought it says ‘The package cache file is corrupted‘. This is really easy to ‘fix’.

Handling “Unable to parse package file” error in Ubuntu and Debian-based Linux distributions

Unable To Parse Package File

Here’s what you need to do. Take a closer look at the name and path of the file the Ubuntu is complaining about.

Reading package lists… Error!
E: Unable to parse package file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_InRelease
E: The package lists or status file could not be parsed or opened.

For example, in the above error, it was complaining about /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_InRelease

This gives you the idea that something is not right with this file. Now all you need to do is to remove this file and regenerate the cache.

sudo rm <file_that_is_not_parsed>

So in my case, I could use this command: sudo rm /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_InRelease and then rebuild the cache with sudo apt update command.

Step by step for beginners

If you are familiar with Linux commands, you may know how to delete the file with its absolute path. For novice users, let me guide you to delete the file safely.

First, you should go to the directory where the file is stored:

cd /var/lib/apt/lists/

Now delete the file which is not being parsed:

sudo rm archive.ubuntu.com_ubuntu_dists_bionic_InRelease

Now if you run the update again, the apt cache will be regenerated.

sudo apt update

Too many files cannot be parsed?

This is fine if you have one or two files that are not being parsed while updating the system. But if the system complains about ten or twenty such files, removing them one by one is too tiring.

What you can do in such a case to remove the entire cache and then generate it again:

sudo rm -r /var/lib/apt/lists/*
sudo apt update

Explanation of how it fixed your problem

The /var/lib/apt is the directory where files and data related to the apt package manager are stored. The /var/lib/apt/lists is the directory that is used for storing information for each package resource specified in your system’s sources.list.

In slightly noncomplicated terms, this /var/lib/apt/lists stores the package information cache. When you want to install or update a program, your system checks in this directory for the information on the said package, if it finds the detail on the package, then it goes to the remote repository and actually downloads the program or its update.

When you run the sudo apt update it builds the cache. This is why even when you remove everything in the /var/lib/apt/lists directory, running the update will build a fresh cache.

This is how it handles the issue of files not being parsed. Your system complained about a particular package or repository information that somehow got corrupted (either a failed download or manual change to the sources.list). Removing that file (or everything) and rebuilding the cache solves the issue.

Still facing error?

This should fix the issue for you. But if the problem still persists or if you have some other related issue, let me know in the comment section and I’ll try to help you out.

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries 🕵️‍♂️

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

It's FOSS

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.