Package dependency conflicts: how to resolve

Topic: Servers linux

Summary

When apt or dnf reports dependency conflicts or broken packages: identify the conflicting packages, choose to remove or replace, use --fix-broken or manual dependency resolution. Use this when install or upgrade fails due to dependency loops or version conflicts.

Intent: Troubleshooting

Quick answer

  • Read the error: note which package requires what and which conflicts; try apt --fix-broken install or dnf install with the suggested packages.
  • Debian: apt-cache policy PACKAGE to see versions; hold a package (apt hold) to avoid upgrade, or remove the conflicting package and find an alternative.
  • Last resort: remove the broken package with --force-remove-reinstreq (dpkg) or rpm -e --nodeps; reinstall from repo or use a different version; avoid mixing repos that conflict.

Prerequisites

Steps

  1. Reproduce and capture the error

    Run apt install PACKAGE or dnf install PACKAGE; copy the dependency/conflict message; note the package names and versions involved.

  2. Try automated fix

    apt --fix-broken install; dnf install (with suggested deps); if upgrade, try apt full-upgrade or dnf upgrade and accept the proposed solution.

  3. Manual resolution

    apt-cache policy pkg; apt hold pkg to pin; remove one side of the conflict (apt remove) then install the other; or install a different version from another repo if available.

  4. Force remove only if necessary

    dpkg --remove --force-remove-reinstreq PACKAGE; then apt install PACKAGE to reinstall clean, or leave removed and use alternative; document what was done.

Summary

You will resolve package dependency and conflict errors by reading the message, trying automated fix, then manually holding, removing, or replacing packages. Use this when install or upgrade is blocked by dependencies.

Prerequisites

  • Root; understanding of which packages are essential so you do not remove something critical.

Steps

Step 1: Reproduce and capture the error

Run the failing install/upgrade and save the full error output.

Step 2: Try automated fix

sudo apt --fix-broken install
sudo dpkg --configure -a
# or
sudo dnf install PACKAGE

Step 3: Manual resolution

  • Use apt-cache policy or dnf list to see versions; hold (apt hold) or exclude (dnf) a package; remove the conflicting package and install an alternative.

Step 4: Force remove only if necessary

sudo dpkg --remove --force-remove-reinstreq PACKAGE
sudo apt install PACKAGE

Document the change for future reference.

Verification

  • Package manager runs without dependency errors; the desired package is installed or a known alternative is in place.

Troubleshooting

Conflict between repos — Disable one repo or pin priorities so the correct repo wins; avoid mixing third-party repos that ship the same package.

Essential package would be removed — Do not force-remove essential packages; fix the dependency chain (install the right version) or use a different approach (container, static binary).

Next steps

Continue to