How to Fix a Problem with Mergelist or Status Files That Could Not be Parsed

It’s not that difficult to fix the error problems with mergelist or status files that could not be parsed with the help of some basic troubleshooting steps.

A friend of mine, while exploring his system, made some changes to the /var/lib/dpkg/status directory and is now stuck with the error message.

Now he cannot update his system or install any applications, but one thing that always comes up on his screen is

  • E: Encountered a section with no Package: header
  • E: Problem with MergeList /var/lib/dpkg/status
  • E: The package lists or status file could not be parsed or opened.

And later, he messed up more with his system and brought up the new error by deleting the status file from his system, which you can see below.

  • Reading package lists… Error!
  • E: flAbsPath on /var/lib/dpkg/status failed – realpath (2: No such file or directory)
  • E: Could not open file  – open (2: No such file or directory)
  • E: Problem opening  
  • E: The package lists or status file could not be parsed or opened.

If you are also one of them who has abruptly made changes to the status file or removed it, or if it’s corrupted due to any unknown reason, then stay with me.

I’ll show you how to fix this error by removing some more files, and then we will update the system repository to rebuild the package lists.

How to Fix Mergelist or Status Files That Could Not be Parsed Error

As you know, the rm command is a destructive one that can completely wipe out your system if you don’t use it carefully.

Therefore, I’m iterating on the steps that we are going to take.

  • Step 01: Remove all the file content from /var/lib/apt/lists/*
  • Step 02: We rebuild repository cache

If the problem is not yet resolved and you are getting status failed – realpath (2: No such file or directory), then we will jump to the second method to restore the status file.

So let’s resolve the error now.

Step 01: Remove all the File Content from /var/lib/apt/lists/*

Open your system terminal and delete all the files from the /var/lib/apt/lists/ using the below command:

$ sudo rm /var/lib/apt/lists/* -vf

Now, if you are pondering why I told you to remove the file, it is because the files in the /var/lib/apt/lists used by system to store and hold the information about the avaible pacakge.

So, whenever you try to install any application, it first checks the information in /var/lib/apt/lists. If it finds the details, it goes online and fetches the application for you.

Now, by removing the content, you are basically clearing up the cache of package information stored in the /var/lib/apt/lists directory,which may trigger the error.

Step 02: Rebuild the Repository Cache

Once you delete the file content from the /var/lib/apt/lists directory, you need to rebuild the repository cache.

To do this, you need to run the following command into the terminal screen:

$ sudo apt update

After running the above command, you’re problem will get resolved, but if the problem is still there with the error “status failed – realpath (2: No such file or directory), then you have to make few more changes to fix this.

How to Fix E: flAbsPath on /var/lib/dpkg/status failed – realpath (2: No such file or directory)

When you read the error, it basically says there is a missing status file in the /var/lib/dpkg directory, which causes the error, and due to that, you are not able to update and install applications.

So to restore the status file, you can look for the status-old file in /var/lib/dpkg by running the below command:

$ locate /var/lib/dpkg "status"

If the status-old file is present, then you can easily restore the changes by renaming status-old to status, and then you should update the repository to refresh the package information.

$ sudo mv /var/lib/dpkg/status-old /var/lib/dpkg/status

For any reason, if the status-old file is not available at the corresponding location, you can restore the status file from /var/backups/dpkg.status.*.gz.

To extract one of the status files from the corresponding directory, execute the below command:

$ sudo gunzip /var/backups/dpkg.status.0.gz  

Once you have successfully extracted the file, place the status file in /var/lib/dpkg/ using the next line of command and update the system.

$ sudo cp -v /var/backups/dpkg.status.0 /var/lib/dpkg/status
$ sudo rm -r /var/lib/apt/lists/*
$ sudo apt update

If it is still not working, then you can create a virtual machine of the same distribution and version and copy the status file from the virtual machine to your host system using the scp command, then try to update the system.

As far as I know, after following the above steps, your problem will no longer exist on your system.

How to Fix Unable to Parse Package File in Debian

If you are getting E: Unable to parse package file /var/lib/apt/extended_states (1) into your Debian machine, run the following command into your system:

$ sudo rm -rf /var/lib/apt/extended_states
$ sudo apt update

Wrap up

That’s all for this article to resolve the status files could not be parsed error on your Ubuntu machine and also on your Debian-based system.

If your problem still persists, feel free to comment below, and I’ll try to help you out.

Here is a summary of the commands that I have used in this guide to solve the problem.

  • Fix problem with MergeList /var/lib/dpkg/status
    • $ sudo rm /var/lib/apt/lists/* -vf
    • $ sudo apt update
  • Fix status failed – realpath (2: No such file or directory)
    • $ sudo mv /var/lib/dpkg/status-old /var/lib/dpkg/status
    • $ sudo apt update
  • Fix unable to parse package file in Debian
    • $ sudo rm -rf /var/lib/apt/extended_states
    • $ sudo apt update

See you in the next article…

Leave a Reply

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.