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.
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).
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.
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.
E: Could not connect to proxy server
Could not connect to proxy server
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt
E: The value 'value' is invalid for APT::Default-Release
How to fix invalid APT::Default-Release value in APT
dpkg: error: unable to create new file 'path': Permission denied
How to fix dpkg permission denied errors in APT
subprocess installed post-removal script returned error exit status 1
How to fix "subprocess installed post-removal script returned error exit status 1" in APT