When apt package manager encounters broken dependencies, it prompts you to run 'apt --fix-broken install'. This error indicates that your package dependency chain is broken and needs repair before you can install or upgrade packages.
Unmet dependencies occur when the apt package manager detects that one or more packages require other packages that are either missing, incompatible, or not installed. This typically happens during package installations, upgrades, or removals when a package's required dependencies cannot be satisfied. The package manager intentionally blocks the operation to prevent system instability. The error suggests running 'apt --fix-broken install' to automatically resolve dependency issues by downloading and installing the required packages. However, this command sometimes fails if the dependency conflict is too complex or if problematic packages need to be removed.
First, update your package cache and try the automatic fix suggested by apt:
sudo apt-get update
sudo apt --fix-broken installThis command tells apt to download and install any missing dependencies. If this succeeds, your issue is resolved.
If the above fails, check if any packages are held (prevented from being upgraded/removed):
apt-mark showholdIf packages are held, they may prevent dependency resolution. You can unhold them with:
sudo apt-mark unhold package-name
sudo apt --fix-broken installReplace package-name with the actual package name shown in the hold list.
For more detailed information about what's causing the dependency conflict:
sudo apt-get -o Debug::pkgProblemResolver=yes dist-upgradeThe verbose output will show which packages are conflicting and why. This helps you understand what's happening so you can make informed decisions about which packages to remove or downgrade.
The aptitude package manager is often better at resolving complex dependency conflicts than apt-get:
sudo apt-get install aptitude
sudo aptitude install -fAptitude uses more sophisticated algorithms to find solutions and may succeed where apt-get fails. It may suggest removing or downgrading conflicting packages.
If previous steps fail, you may need to remove the packages causing the conflict. First, use apt to show which packages are broken:
sudo apt-get checkOnce you identify the problematic package, try a dry run first:
sudo apt-get remove --dry-run package-nameIf the dry run looks safe, remove it:
sudo apt-get remove package-name
sudo apt --fix-broken installThen you can reinstall the package or find a compatible alternative version.
If a package is causing conflicts, you can explicitly install a compatible version:
sudo apt-get install package-name=version-numberFirst, see available versions:
apt-cache policy package-nameThis shows all available versions in your repositories. Choose a compatible one and install it explicitly.
For persistent issues, investigate your APT sources. Third-party PPAs (Personal Package Archives) are a common culprit. List your sources with 'software-properties-gtk' or by checking '/etc/apt/sources.list' and '/etc/apt/sources.list.d/'. Disabling problematic repositories often resolves unmet dependencies. If you're using containers or cloud instances, ensure your base image's package repositories are compatible with any third-party packages you're adding. Some distributions (Ubuntu, Debian, Linux Mint) have slightly different repository configurations that can cause conflicts if mixed.
dpkg: serious warning: files list file for package 'package-name' contains empty filename
How to fix "files list file contains empty filename" in APT
E: Sub-process /usr/bin/dpkg returned an error code (2)
How to fix "Sub-process /usr/bin/dpkg returned an error code (2)" in APT
dpkg-divert: error: rename involves overwriting 'path' with different file
How to fix dpkg-divert rename conflicts in APT
E: Sub-process /usr/bin/dpkg returned an error code (1) during kernel installation
How to fix "dpkg returned an error code (1)" in APT kernel installation
dpkg: dependency problems prevent configuration of triggers
dpkg: dependency problems prevent configuration of triggers in apt