Fading Coder

An Old Coder’s Final Dance

Home > Tech > Content

Fix dpkg warnings about missing files list for packages

Tech 3

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

  1. Save the wranings to a file
  • Copy/paste the warnings in to a text file, for example warnings.txt.
  1. 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
  1. Make it executable
chmod +x fix-missing-lists.sh
  1. 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[@]}"

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.