The "E: Unmet dependencies. Try using -f" error occurs when apt package dependencies are broken. The -f flag (or --fix-broken) tells apt to automatically install missing dependencies and resolve conflicts to repair your package system.
Unmet dependencies happen when the apt package manager detects that installed or installable packages have unsatisfied requirements. The error suggests using the -f flag as a quick automatic fix. This flag instructs apt to download and install any missing packages needed to satisfy dependencies, which typically resolves most broken dependency situations. Without the -f flag, apt refuses to perform the requested operation to prevent system corruption. The -f flag enables "fix-broken" mode, allowing apt to take corrective action. In some cases, apt may need to remove conflicting packages to resolve the issue.
First, refresh your package cache to ensure apt has the latest package information:
sudo apt updateThis synchronizes your local package index with the latest available packages in your repositories. Often, simply updating the cache can resolve dependency issues.
Run apt install with the -f flag to automatically fix broken dependencies:
sudo apt install -fOr using apt-get:
sudo apt-get install -fThe -f flag (short for --fix-broken) tells apt to:
- Identify missing packages required by other packages
- Download and install those missing packages
- Remove packages that cannot have their dependencies satisfied
This command requires no package names - apt automatically determines what needs to be fixed.
After running the above command, verify the system is healthy:
sudo apt checkIf this command completes without errors, your package system is repaired. Try your original operation again:
sudo apt install package-nameIf apt still shows issues, combine the fix with autoremove to eliminate unused packages:
sudo apt install -f
sudo apt autoremoveThe autoremove command removes packages that were automatically installed as dependencies but are no longer needed. This often resolves lingering dependency conflicts.
If apt install -f doesn't work, dpkg (the lower-level package manager) may need to finish configuring partially-installed packages:
sudo dpkg --configure -a
sudo apt install -fThe -a flag tells dpkg to configure all unconfigured packages. Run this before apt install -f for best results.
If basic fixes fail, dist-upgrade (distribution upgrade) sometimes has better dependency resolution:
sudo apt-get dist-upgradeWarning: dist-upgrade may upgrade or downgrade packages. It's more aggressive than regular upgrade but sometimes necessary for complex dependency situations. Always review the changes it proposes before confirming.
The -f flag is a shortcut for --fix-broken. Both do exactly the same thing. The single-letter flag is often preferred in scripts and commands for brevity.
If you're still having issues after using -f:
1. Check your APT sources: Third-party PPAs are frequently the culprit. Review '/etc/apt/sources.list' and '/etc/apt/sources.list.d/'. Consider disabling PPAs temporarily to see if they cause the issue.
2. Use apt --fix-missing instead: This variant is sometimes more conservative: sudo apt install --fix-missing.
3. Check held packages: Held packages (marked to not upgrade) can prevent dependency resolution. List them with apt-mark showhold. Remove holds if needed: sudo apt-mark unhold package-name.
4. Try aptitude: The aptitude package manager uses more sophisticated algorithms: sudo aptitude install -f. First install it: sudo apt install aptitude.
5. Last resort - identify and remove the conflicting package manually using apt-get check to see what's broken, then remove it with sudo apt remove package-name.
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