How to Check for Broken Packages on Arch Linux

How to Check for Broken Packages on Arch Linux

Arch Linux is a flexible, rolling-release Linux distribution that provides users with cutting-edge software and an unparalleled degree of customization. However, with great power comes great responsibility — especially when it comes to package management. Since Arch users are often compiling from the AUR (Arch User Repository), using bleeding-edge packages, or mixing software from multiple sources, it’s not uncommon to encounter broken packages.

Broken packages can lead to a variety of issues such as:

  • Missing dependencies
  • Partially installed software
  • Conflicting packages
  • Damaged package databases
  • Inconsistent system states

This article will guide you through how to identify, analyze, and resolve broken packages on Arch Linux using various tools and best practices.


1. Understanding What “Broken Package” Means

In the context of Arch Linux, a “broken package” can refer to several things:

  • A package that is installed but missing dependencies
  • A package that has corrupted files or incomplete installation
  • A partial upgrade, leading to version conflicts
  • Orphaned packages that no longer serve a purpose or are misconfigured
  • Packages from the AUR that fail to compile or install properly

To maintain a healthy Arch system, it’s essential to routinely check for these conditions and take corrective action.


2. Checking the System for Broken Dependencies

The first step is to verify that your installed packages are not missing any required dependencies.

2.1 Use pacman -Qk

The -Qk option checks for missing files that belong to a package.

pacman -Qk

To limit output to only problematic packages:

pacman -Qk | grep -v '0 missing files'

This will return packages with missing files, indicating possible corruption or deletion.

📝 Note: Missing files do not always mean the package is broken. Sometimes files are moved manually or removed by other programs.

2.2 Use pacman -Qdt for Orphans

Orphaned packages are dependencies that were installed as part of another package but are no longer required.

pacman -Qdt

To remove these:

sudo pacman -Rns $(pacman -Qdtq)

Removing orphans can clean up the system, but proceed cautiously, especially if you’re using AUR helpers that may mislabel dependencies.


3. Verifying the Integrity of Installed Packages

If you suspect package corruption, you can validate package files against the package database.

3.1 Use pacman -Qkk

This command checks each installed file against the package’s file list and reports missing or altered files.

sudo pacman -Qkk

Filter for abnormal output:

sudo pacman -Qkk | grep -v ': 0 altered files'

If files are reported as “missing” or “altered,” you might want to reinstall the affected packages:

sudo pacman -S package_name

4. Using pactree to Identify Dependency Chains

Sometimes a broken package may still exist in a dependency tree, creating issues down the line.

pactree package_name

You can use this to verify whether a problematic package is needed by any other packages or is safe to remove.

For example:

pactree -r package_name

This shows reverse dependencies (what depends on this package).


5. Repairing a Broken Package Database

Corrupted or out-of-sync package databases can lead to errors like “package not found” or “invalid or corrupted package (PGP signature).”

5.1 Refresh the Local Package Database

sudo pacman -Syy

This forces a complete refresh of the package list.

5.2 Reinstall the Package Database

If the local database is seriously broken:

sudo pacman -Syu --noconfirm

This ensures the system is fully up to date and may resolve partial upgrades.


6. Resolving Conflicts from Partial Upgrades

One of the golden rules in Arch Linux is: “Always update your system fully, not partially.” A broken package may result from skipping updates or only updating select packages.

6.1 Use Full System Upgrade

sudo pacman -Syu

This brings all packages in sync with their latest versions, reducing the risk of conflicts.

6.2 Check for Partial Upgrades or Held Packages

Sometimes users manually hold a package version to avoid an unwanted upgrade, which can later break dependencies.

Check for ignored packages in /etc/pacman.conf:

IgnorePkg   = packagename

If found, consider whether it’s safe to update them or remove the ignore rule.


7. Handling AUR Packages

Arch’s AUR is a fantastic resource but can also be a source of broken packages, especially when PKGBUILDs are outdated or dependencies change upstream.

7.1 Use a Reliable AUR Helper

Examples include:

  • yay
  • paru
  • trizen
yay -Syu

This updates AUR and official repo packages together.

7.2 Check for AUR Build Failures

If a package fails to build, read the build output carefully. Common issues include:

  • Missing dependencies
  • Outdated PKGBUILD scripts
  • Upstream project changes

To rebuild a problematic AUR package:

yay -S package_name --rebuild

You can also flag a broken AUR package on the AUR web interface so maintainers are aware.


Sometimes a broken package leaves behind dead symbolic links.

Use find to locate these:

find / -xtype l 2>/dev/null

Review them carefully. If they point to uninstalled packages or files, they might indicate leftover traces of broken software.


9. Use Third-Party Tools

9.1 checkupdates (from pacman-contrib)

This tool lets you safely check for available updates without running pacman -Syu.

checkupdates

You can install it with:

sudo pacman -S pacman-contrib

9.2 debtap for Foreign Packages (Optional)

If you install non-Arch packages (like .deb files), use caution. They can break your package manager.


10. Log Analysis

If something broke recently, check your pacman logs to trace the cause:

less /var/log/pacman.log

Look for errors like:

  • “conflicting files”
  • “unable to satisfy dependency”
  • “invalid or corrupted package”

11. Recovering From Major Package Breakages

If your system is heavily broken, here are recovery strategies:

11.1 Use a Live ISO and chroot

Boot into an Arch ISO, mount your partitions, and arch-chroot into your system:

mount /dev/sdXn /mnt
arch-chroot /mnt

From here, you can fix your system with pacman.

11.2 Use pacstrap to Reinstall Base

If core components are broken:

pacstrap /mnt base linux linux-firmware

Recheck bootloader and system configs before rebooting.


Conclusion

Broken packages on Arch Linux can range from minor annoyances to major system failures, but with the right tools and knowledge, they’re usually fixable. By routinely checking for orphaned packages, validating installed files, using full system upgrades, and being cautious with AUR packages, you can maintain a clean and stable Arch environment.

Here are some final tips:

  • Always use pacman -Syu for full upgrades.
  • Use AUR helpers wisely and read PKGBUILD files before installing.
  • Keep your /var/log/pacman.log for troubleshooting.
  • Rebuild or reinstall suspicious packages.
  • When in doubt, consult the Arch Wiki or forums — they’re an invaluable resource.

By staying proactive and vigilant, you’ll ensure that your Arch Linux system remains as robust as it is bleeding-edge.