Fix dpkg warnings about missing files list for packages
When apt/dpkg reports messages like "files list file for package … missing; assuming package has no files currently installed", it usually means the package’s .list metadata under /var/lib/dpkg/info is gone. The safest fix is to reinstall the affected packages.
Below is a small workflow and script to automate the reinstall of every package mentioned in the warnings.
Example warning output
You may see lines similar to:
dpkg: warning: files list file for package 'xorg-docs-core' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libgcc1:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'xfonts-base' missing; assuming package has no files currently installed
Steps
- Save the wranings to a file
- Copy/paste the warnings in to a text file, for example warnings.txt.
- Create a reinstall script
Create a file named fix-missing-lists.sh in the same directory as warnings.txt with the following content:
#!/usr/bin/env bash
set -euo pipefail
LOG_FILE=${1:-warnings.txt}
if [[ ! -r "$LOG_FILE" ]]; then
echo "Usage: $0 <warnings-file>" >&2
exit 1
fi
# Extract package names between single quotes, deduplicate, and reinstall
mapfile -t packages < <(
grep -E "^dpkg: warning: files list file for package '" "$LOG_FILE" \
| awk -F"'" '{print $2}' \
| sort -u
)
if (( ${#packages[@]} == 0 )); then
echo "No packages found in $LOG_FILE" >&2
exit 0
fi
# Pick apt-get if available, otherwise apt
APT_TOOL="apt-get"
command -v apt-get >/dev/null 2>&1 || APT_TOOL="apt"
count=1
for pkg in "${packages[@]}"; do
echo "[$count/${#packages[@]}] Reinstalling $pkg"
sudo "$APT_TOOL" -y --reinstall install "$pkg"
((count++))
done
- Make it executable
chmod +x fix-missing-lists.sh
- Run the script
sudo ./fix-missing-lists.sh warnings.txt
Alternative: Detect missing .list files without pasting logs
You can also scan dpkg’s info directory directly and reinstall any package whose .list file is missing:
#!/usr/bin/env bash
set -euo pipefail
# Enumerate installed packages and check their .list files
mapfile -t pkgs < <(
dpkg-query -W -f='${binary:Package}\n' \
| while read -r p; do
[[ -e "/var/lib/dpkg/info/${p}.list" ]] || echo "$p"
done \
| sort -u
)
if (( ${#pkgs[@]} == 0 )); then
echo "No packages with missing .list files detected"
exit 0
fi
APT_TOOL="apt-get"
command -v apt-get >/dev/null 2>&1 || APT_TOOL="apt"
sudo "$APT_TOOL" -y --reinstall install "${pkgs[@]}"