Fix 'Dependency Conflicts' in APT on Ubuntu 22.04
Package manager says dependencies can't be met? I've been there. Here's how to fix it without breaking your system.
Quick answer: Run sudo apt --fix-broken install then sudo apt update && sudo apt upgrade. If that fails, use sudo dpkg --configure -a and sudo apt-get install -f.
I know this error is infuriating. You try to install something simple like gimp or python3-pip, and suddenly apt throws a tantrum about unmet dependencies. It says things like "package foo depends on bar but bar is not going to be installed." This tripped me up the first time too, back when I was running Ubuntu 18.04.
Here's what's happening: when you mix PPAs, third-party repos, or manually installed .deb files, apt's resolver gets confused. It can't find a version of a package that satisfies all the requirements across repos. This is called "dependency hell."
Step-by-Step Fix (try these in order)
1. Try the automatic fix first
Run this command. It'll try to fix broken packages automatically:
sudo apt --fix-broken install
This will scan your system for unsatisfied dependencies and either install missing packages or remove broken ones. Usually fixes 70% of cases.
2. Reconfigure all unpacked packages
If step 1 fails, some packages might be half-installed. Run:
sudo dpkg --configure -a
This finishes configuring any packages that were left in a weird state after a canceled install or power loss.
3. Force the install (use with caution)
Still stuck? You can tell apt to ignore version checks for a specific package. For example, if libssl1.1 is missing but you have libssl3, try:
sudo apt-get install -o APT::Get::Fix-Policy=1 libssl1.1
Or use the nuclear option – force overwrite files:
sudo dpkg -i --force-overwrite /var/cache/apt/archives/package-name.deb
Replace package-name.deb with the actual file name. You can see cached packages with ls /var/cache/apt/archives/.
4. Remove the conflicting package (last resort)
If nothing works, remove the package that's causing the conflict. Let's say it's libfoo1. Run:
sudo apt-get remove --purge libfoo1
Then run sudo apt update && sudo apt upgrade again. The package manager will rebuild its dependency tree.
Alternative Fixes If the Main One Fails
Hold packages at current version
Sometimes a package from a PPA wants a newer version of a library that conflicts with Ubuntu's official repos. You can hold the library at the current version so apt stops trying to upgrade it:
sudo apt-mark hold libssl1.1
Replace libssl1.1 with the actual package name. This tells apt to never upgrade that package.
Pinning packages to a repo
If you have a specific repo that should provide a package, create a pinning file. For example, to prefer packages from Ubuntu's main repo over a PPA:
sudo nano /etc/apt/preferences.d/mypin
Add this content:
Package: *
Pin: release a=focal
Pin-Priority: 1001
Replace focal with your Ubuntu version code (focal for 20.04, jammy for 22.04). Then run sudo apt update.
Use aptitude for advanced dependency resolution
Install aptitude:
sudo apt-get install aptitude
Then run sudo aptitude install package-name. Aptitude is smarter about finding a valid package combination. It'll present you with options if the default resolution causes conflicts.
Prevention Tip
Don't mix PPAs and third-party repos for the same package. If you add a PPA for something like php, don't also install php from a .deb file or another repo. Stick to one source per package.
Also, when a new Ubuntu version comes out (like 24.04), do a clean upgrade. Don't carry over old PPAs from 22.04 – they often have incompatible versions. Remove the PPA before upgrading:
sudo add-apt-repository --remove ppa:example/ppaWas this solution helpful?