Installing software or updating packages in Ubuntu can be abruptly halted by an APT dependency deadlock: You have held broken packages or Unmet dependencies. Try ‘apt –fix-broken install’ (or ‘apt-get install -f’) with no packages. When this condition occurs, the Advanced Package Tool (APT) refuses to install new software, remove packages, or process system upgrades. In severe situations, running apt-get install -f itself returns failure codes due to half-installed package scripts or package architecture conflicts.
Restoring a clean APT package management state requires reconfiguring unconfigured packages with dpkg, removing orphaned lock files, and clearing conflicting third-party PPA packages.
What Causes Broken Dependencies in Ubuntu Linux?
Ubuntu enforces strict package version requirements declared in package control manifests. Broken dependencies occur when:
- Interrupted Package Installation: System restarts, power loss, or pressing
Ctrl + Cduring an ongoing installation leavesdpkgstatus records in a half-configured state. - Incompatible Third-Party PPAs: Adding repositories configured for a different Ubuntu release (e.g. attempting to install Noble Numbat packages on Jammy Jellyfish) requesting missing shared library versions.
- Manual .deb Installations via dpkg: Installing packages directly via
sudo dpkg -i package.debwithout pulling the required upstream dependencies. - Corrupted APT Cache Lists: Truncated or fragmented package lists inside
/var/lib/apt/lists/leading to version mismatch calculations. - Conflicting Multi-Arch Libraries: Parallel installations of 32-bit (
i386) and 64-bit (amd64) packages demanding diverging glibc or runtime dependencies.
Step 1: Execute the Standard Broken Install Repair Command
APT includes an automated dependency resolver designed to download and install missing prerequisite packages:
- Open a terminal window.
- Execute the fix-broken command:
(or the legacy syntax:sudo apt --fix-broken installsudo apt-get install -f) - Review the proposed solutions. If APT offers to install missing dependencies cleanly, press
Yand hit Enter. - If the command completes successfully, run
sudo apt update && sudo apt upgradeto confirm normal package servicing is restored.
Step 2: Reconfigure Unfinished Packages with dpkg
If APT cannot run because a package was left half-installed or post-install scripts failed:
- Reconfigure all unpacked but unconfigured packages:
sudo dpkg --configure -a - If an error indicates that a lock file is preventing execution, verify no other package manager is active (e.g. Software Updater), then remove stale locks:
sudo rm -f /var/lib/dpkg/lock-frontend sudo rm -f /var/lib/dpkg/lock sudo rm -f /var/lib/apt/lists/lock sudo dpkg --configure -a
Step 3: Force Remove the Offending Package
If a specific manual .deb package is causing an unresolvable conflict, remove it directly using dpkg:
- Identify the problematic package name from the terminal error output (e.g.
package-name). - Force remove the package ignoring dependency checks:
sudo dpkg -r --force-depends package-name - Once removed, run the fix-broken command again to satisfy remaining system libraries:
sudo apt --fix-broken install
Step 4: Clean and Regenerate APT Cache Lists
Corrupted local repository indices frequently misreport package availability:
- Purge the local package download archive:
sudo apt clean sudo apt autoclean - Delete all cached package lists:
sudo rm -rf /var/lib/apt/lists/* - Re-download pristine package manifests from Ubuntu repositories:
sudo apt update
Step 5: Purge Problematic PPAs with ppa-purge
If the broken dependencies originated from an incompatible third-party PPA:
- Install the PPA purge utility:
sudo apt install ppa-purge - Downgrade all packages from the problematic PPA back to standard official Ubuntu repository versions:
sudo ppa-purge ppa:problematic-repository/ppa - Execute a system upgrade to verify dependency tree integrity:
sudo apt update && sudo apt dist-upgrade