Fix an APT installation blocked by dependency conflicts
Steps to unblock apt when packages stay held back or have unresolved dependency conflicts.
When apt-get refuses to install or upgrade a package because of conflicting dependencies, the following steps repair the package state.
1. Finish an interrupted configuration
sudo dpkg --configure -a
sudo apt-get -f install
2. Full upgrade
sudo apt-get -u dist-upgrade
If packages remain held back (not upgraded), apt could not resolve their dependencies. The resolver debug mode shows the conflicts:
sudo apt-get -o Debug::pkgProblemResolver=yes dist-upgrade
3. Remove conflicting packages one at a time
Remove the blocking package, then run dist-upgrade again. Always simulate first:
sudo apt-get remove --dry-run package-name
Reinstall the packages you need once the conflicts are gone.
Alternative
If removing the package you want to install is not acceptable, look for a repository that provides the missing dependencies (see APT pinning) instead of removing packages.
Notes
- The
--dry-runoption shows the consequences without changing anything: use it before everyremove. - Removing a package can also remove the packages that depend on it.