How to fix E: Unable to parse package file in APT
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- Identify the problematic file
- Remove the corrupted cache file
- Clear all apt cache and rebuild (for multiple errors)
- Handle extended_states errors
sudo apt-get checkE: 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
- 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
- Corrupted package cache from interrupted previous apt operations
- File truncation or corruption from disk errors or power loss
- Incompatible package paragraph sizes in older apt versions
How to fix "E: Unable to parse package file"
Run the check command to see detailed error information:
sudo apt-get checkThis will show you which specific file is corrupted, usually a path in /var/lib/apt/lists or /var/lib/dpkg/status.
If the error points to a specific file in /var/lib/apt/lists, remove just that file:
sudo rm /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal_InReleaseReplace the filename with the one shown in your error message. Then rebuild the cache:
sudo apt updateIf multiple cache files are corrupted, clear the entire cache directory and regenerate it:
sudo rm -rf /var/lib/apt/lists/*
sudo mkdir -p /var/lib/apt/lists/partial
sudo apt updateThis safely removes all cached package information and rebuilds it fresh from your repositories.
If the error mentions /var/lib/apt/extended_states, temporarily rename this tracking file:
sudo mv /var/lib/apt/extended_states /var/lib/apt/extended_states.bak
sudo apt updateThe file will be automatically recreated when apt next runs.
If the error is in /var/lib/dpkg/status, you can restore from a recent backup:
sudo cp /var/backups/dpkg.status.0 /var/lib/dpkg/status
sudo apt updateThe backup directory typically contains daily snapshots of the dpkg database.
If the error originated from /etc/apt/sources.list or /etc/apt/sources.list.d/, check for syntax errors:
sudo nano /etc/apt/sources.listVerify 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.
After making changes, test that apt works:
sudo apt update
sudo apt install -s test-packageThe 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.