How to Fix the “The following packages have unmet dependencies” Error

Installing packages by utilizing the apt repository is a crucial aspect of the Debian-based operating systems. The “apt” package manager helps to retrieve and install numerous packages on Debian-based Linux systems. While using the apt repository, a familiar problem may be encountered with the statement “The following packages have unmet dependencies”.

This article will provide reasons for this problem and a detailed explanation of how these errors can be resolved.

How to Fix “The following packages have unmet dependencies” Error?

There exist a couple of reasons that can invoke this issue on your system. This section will list all of these reasons and also provide potential solutions for these reasons.

Reason 1: Dependencies are Broken, or the Repository is Corrupted

The common cause of this error is that there are broken dependencies (missing or corrupted dependencies) for the package on your system. In other cases, the repository can be corrupted due to some system fault or incomplete updates. When these problems happen, the system will not be able to install the package from the repository.

Solution 1: Fix the Dependencies

Top 10 Linux Distros

The solution for this issue is to use the “-f” parameter to fix the dependencies as follows:

$ sudo apt install -f

The next step is to reconfigure the package manager, which can be achieved by executing the command shown below:

$ sudo dpkg --configure -a

Once the package manager has been successfully reconfigured, run the repository command again on the system to fix the broken dependency issue:

$ sudo apt install -f

Once you have completed these steps, install the package once again and the error will be resolved.

Solution 2: Fix the Repository

Another simple solution to this problem is to clean the repository and fix its corrupted parts. For this purpose, the following simple command is used, which will thoroughly clean the repository as demonstrated below:

$ sudo apt autoclean

Solution 3: Utilize the Aptitude Package Installer

Instead of fixing the apt installer and its dependencies, the other option is to simply make use of a different package manager named “Aptitude”, and it can be installed via the command stated below:

$ sudo apt install aptitude

This command will install the aptitude software onto your system.

Instead of the apt tool, you can now utilize the aptitude to install any packages that you require. This will also automatically fix any dependencies:

$ sudo aptitude install package_name

Reason 2: Packages with Unmet Dependencies are Held

Sometimes, the system will hold any package whose dependencies are unmet. When this happens, the system will prompt this error every time you attempt to install any new package. To get a list of the packages that have been held by the system, run the following command:

$ sudo apt -u dist-upgrade

Solution 1: Debug and Upgrade the Packages

To resolve this issue, the best fix is to debug all the packages that are listed in the snippet from running the command for the upgrade. The command shown below will automatically debug all the packages and then upgrade them to remove the error:

$ sudo apt -o Debug::pkgProblemResolver=yes dist-upgrade

Solution 2: Remove the Packages

If the solution above does not resolve the issue and you still are unable to upgrade these packages as shown in the snippet below:

In this case, the best option is to remove these packages one by one by executing the command shown below:

$ sudo apt remove package_name

Following the syntax mentioned above, the package named “xdg-utils” will be removed from the system:

$ sudo apt remove xdg-utils

That’s it! You will no longer get the error.

Conclusion

The error named “The following packages have unmet dependencies” is invoked if the dependencies are broken, or the repository is corrupted. Another reason is when certain packages are being held back by the system. This error can be resolved by fixing the dependencies, the repository, or using a different package manager. You can also fix this issue by upgrading the packages held back or removing them one by one from the system. This article has successfully demonstrated the possible reasons that invoke this error and all the relevant solutions.