How to fix E: Unable to parse package file in APT

APTINTERMEDIATEMEDIUMUpdated Mar 29, 2026· 259 views

The apt package manager encounters a corrupted package cache file, preventing package list updates or installation. This typically occurs when repository data fails to download cleanly or becomes malformed in the /var/lib/apt/lists directory.

Quick fix

Fixes E: Unable to parse package file

sudo apt-get check
  1. Identify the problematic file
  2. Remove the corrupted cache file
  3. Clear all apt cache and rebuild (for multiple errors)
  4. Handle extended_states errors
apt — error
sudo apt-get check
E: Unable to parse package file

What this error means

When apt displays "E: Unable to parse package file", it means the package manager detected a syntax error or corruption in one of its cache files. These cache files store metadata about available packages from your configured repositories. The error prevents apt from reading package information, blocking system updates and software installation. The corrupted file can be in /var/lib/apt/lists (repository package lists), /var/lib/apt/extended_states (package state tracking), or /var/lib/dpkg/status (installed package database).

Typical symptoms

  • apt update or apt upgrade commands fail with parsing error
  • Software installation attempts halt before download begins
  • System reports "package lists or status file could not be parsed or opened"
  • Error message includes a specific file path like /var/lib/apt/lists/archive.ubuntu.com_ubuntu_...

Common causes

  1. Failed or interrupted download of repository metadata (network outage, killed process)
  2. Manual edits to /etc/apt/sources.list or /etc/apt/sources.list.d files with syntax errors
  3. Malformed repository entries with incorrect formatting or missing spaces
  4. Corrupted package cache from interrupted previous apt operations
  5. File truncation or corruption from disk errors or power loss
  6. Incompatible package paragraph sizes in older apt versions

How to fix "E: Unable to parse package file"

1Identify the problematic file

Run the check command to see detailed error information:

bash
sudo apt-get check

This will show you which specific file is corrupted, usually a path in /var/lib/apt/lists or /var/lib/dpkg/status.

2Remove the corrupted cache file

If the error points to a specific file in /var/lib/apt/lists, remove just that file:

bash
sudo rm /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal_InRelease

Replace the filename with the one shown in your error message. Then rebuild the cache:

bash
sudo apt update
3Clear all apt cache and rebuild (for multiple errors)

If multiple cache files are corrupted, clear the entire cache directory and regenerate it:

bash
sudo rm -rf /var/lib/apt/lists/*
sudo mkdir -p /var/lib/apt/lists/partial
sudo apt update

This safely removes all cached package information and rebuilds it fresh from your repositories.

4Handle extended_states errors

If the error mentions /var/lib/apt/extended_states, temporarily rename this tracking file:

bash
sudo mv /var/lib/apt/extended_states /var/lib/apt/extended_states.bak
sudo apt update

The file will be automatically recreated when apt next runs.

5Restore dpkg status from backup

If the error is in /var/lib/dpkg/status, you can restore from a recent backup:

bash
sudo cp /var/backups/dpkg.status.0 /var/lib/dpkg/status
sudo apt update

The backup directory typically contains daily snapshots of the dpkg database.

6Fix malformed sources.list entries

If the error originated from /etc/apt/sources.list or /etc/apt/sources.list.d/, check for syntax errors:

bash
sudo nano /etc/apt/sources.list

Verify entries follow correct format: deb https://repository.url/ ubuntu-codename main with proper spacing. Check for lines split across multiple lines (they should be on one line). Remove any malformed entries and save.

7Verify the fix

After making changes, test that apt works:

bash
sudo apt update
sudo apt install -s test-package

The second command simulates an install without making changes. If both succeed, the issue is resolved.

Advanced notes

For persistent corruption issues: (1) Enable verbose apt logging with apt -o Debug::pkgProblemResolver=yes update to get detailed parsing information. (2) Check disk health with sudo smartctl -a /dev/sda if corruption occurs frequently—failing drives can cause file system damage. (3) On systems with /var/lib/apt/extended_states issues, this file can be safely removed entirely—it tracks package auto-installed status but is non-critical. (4) Some third-party PPAs add repositories with malformed source lines; try running sudo apt-add-repository --remove ppa:username/ppa-name to remove problematic PPAs. (5) In Docker/containers, use apt-get clean && apt-get update as separate RUN instructions to prevent caching stale package lists across image layers.

Frequently asked questions

What does "E: Unable to parse package file" mean?
When apt displays "E: Unable to parse package file", it means the package manager detected a syntax error or corruption in one of its cache files. These cache files store metadata about available packages from your configured repositories. The error prevents apt from reading package information, blocking system updates and software installation.
How do I fix "E: Unable to parse package file"?
The apt package manager encounters a corrupted package cache file, preventing package list updates or installation. This typically occurs when repository data fails to download cleanly or becomes malformed in the /var/lib/apt/lists directory.
What causes "E: Unable to parse package file"?
Failed or interrupted download of repository metadata (network outage, killed process) Manual edits to /etc/apt/sources.list or /etc/apt/sources.list.d files with syntax errors Malformed repository entries with incorrect formatting or missing spaces
Is the "E: Unable to parse package file" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading