Debug Broken Debian Packages with which-pkg-broke

Package management issues on Debian can cause software to fail unexpectedly when shared libraries or dependencies change. The which-pkg-broke utility, included in the debian-goodies package, simplifies troubleshooting by analyzing the dependency tree of a malfunctioning package and listing its dependencies in order of their installation or upgrade times. This article explains how which-pkg-broke works, how to run it, and how to use its output to pinpoint and resolve broken dependencies on Debian systems.

The Challenge of Debian Dependency Breakage

Debian's package management ecosystem—powered by dpkg and apt—is renowned for its dependency resolution. However, systems pulling packages from mixed repositories (such as combining stable with testing or third-party PPAs) can experience subtle breakages. A newly upgraded shared library might maintain binary compatibility on paper while introducing regressions or removing symbols required by an older, previously working program. When this happens, the affected application crashes or fails to launch, yet apt does not flag any obvious broken packages because all declared dependencies remain technically satisfied.

What is which-pkg-broke?

which-pkg-broke is a specialized diagnostic script provided by the debian-goodies toolbox, a collection of lightweight utilities designed to enhance standard Debian administrative tasks. Rather than checking whether a package's dependencies are physically present, which-pkg-broke investigates the timeline of changes across a package’s entire dependency graph.

The tool inspects the /var/lib/dpkg/info/ metadata directory to determine when each dependent package was last configured or updated. It then correlates this information against the target package, surfacing which upstream components changed recently.

How to Install and Run the Tool

To use which-pkg-broke, install the debian-goodies package via standard package management:

sudo apt update
sudo apt install debian-goodies

Once installed, you can analyze any problematic package by providing its name as an argument:

which-pkg-broke <package-name>

For example, if the video player mpv suddenly stops launching after a system update:

which-pkg-broke mpv

Analyzing Reverse Dependencies

By default, the command inspects packages that your target package depends on. However, if an update to a core package breaks other software on your system, you can use the -b flag to check reverse dependencies (packages that depend on the target):

which-pkg-broke -b <package-name>

This reverse lookup helps identify downstream software impacted by a specific library upgrade.

Interpreting the Output

When executed, which-pkg-broke walks the dependency tree recursively and outputs a list of packages formatted chronologically. The output generally displays:

  1. The target package and its installation timestamp.
  2. Direct and indirect dependencies that were configured after the target package.
  3. The exact dates and times those dependencies were installed or upgraded.

Any dependency installed or updated more recently than the target package represents a potential point of failure. If mpv was installed on June 1st, and an underlying audio library like libasound2 was updated on June 10th right before the application began crashing, that library is the primary suspect.

Resolving Identified Issues

Once which-pkg-broke highlights the most recently modified packages in the dependency tree, you can take targeted action:

  • Inspect Changelogs: Run apt-listchanges or check /usr/share/doc/<package>/changelog.Debian.gz for the culprit package to see what modifications were introduced in the latest release.
  • Downgrade the Culprit: Use apt install <package>=<older-version> to roll back the offending dependency to its prior functioning state.
  • Hold the Working Version: Prevent apt from automatically upgrading the dependency again until a bug fix is released by executing sudo apt-mark hold <package>.
  • File a Bug Report: Use Debian's reportbug tool to submit a detailed report against the offending package, citing the version incompatibility discovered during your analysis.