[Fixed] “You have held broken packages” Error

One of the best things about Linux is the apt command which lets you install applications and software effortlessly. Using apt, you don’t have to go through downloading the software, then going through the installer and clicking ‘Next’ a dozen times. It makes sure that every software is installed with just one terminal command.

But, just like any other program, things can go wrong. The error that we will be talking about in this write-up looks something like the following:

E: Unable to correct problems, you have held broken packages.

This error may occur when you are trying to install something via the apt utility. Let us look into the error in detail and try to solve the problem.

What causes this error?

Some of the software (mostly third-party ones) do not come with compatible dependencies and apt expects that your system already has those components. In case the required components aren’t found on your system, apt throws an error related to broken packages which means that the package you are trying to install is incomplete.

Outdated repositories, problems with the ‘sources.list‘ file, or an old/unsupported version of Linux might be the cause of this problem.

Methods to fix this problem

Before moving to the advanced methods, let us try a few quick tricks that can potentially help:

Method 1: Update the repositories

sudo apt update

The apt update is a well-known command which instantly updates the list of packages and their dependencies. As the problem we are facing is due to missing dependencies, there is a good chance that this command will fix the error.

If the problem persists, try this command:

sudo apt upgrade

This will update the existing packages on your system to the latest version.

Method 2: Use aptitude instead of apt

Aptitude is also a package manager like apt and it surprisingly works in some situations where apt doesn’t! all you need to do is use aptitude instead of apt.

For example, suppose you want to install BIND9 using aptitude, you will have to enter the following command:

sudo aptitude install bind9

If you don’t have aptitude installed, run the following commands:

sudo apt-get update
sudo apt-get install aptitude

Method 3: Use autoremove to get rid of unnecessary packages

Sometimes, unnecessary packages stay behind even after uninstalling their parent application. These residual packages might interfere with installation of new applications or libraries. To get rid of these unnecessary residual packages, just enter the following command into the terminal:

sudo apt autoremove

There’s no need to worry as autoremove will only handle the leftover packages and dependencies.

Now with the basics out of the way, we will look at some more advanced methods to solve this problem.

Method 4: Look for held packages and unhold them

As the error message suggests, the problem is caused by packages on hold. The term ‘held package’ means that it can’t be upgraded, removed, or modified in any way.

To get a list of held packages, you need to enter the following command:

sudo apt-mark showhold

To unhold a specific package, enter:

sudo apt-mark unhold <package-name>

To unhold all held packages, enter:

sudo apt-mark unhold $(sudo apt-mark showhold)

Method 5: Use the synaptic package manager to fix broken packages

Originally, Linux doesn’t have an inbuilt graphical package manager like Windows. This is why the synaptic package manager became immensely popular on Debian-based distributions made for personal computers as it provided a lightweight and robust GUI package manager.

One of the key features of this utility is that you can fix broken packages very easily. Follow the steps below:

1. First, install the synaptic package manager:

sudo apt update
sudo apt install synaptic

2. Run synaptic with superuser privileges:

sudo synaptic

3. Go to Edit > Fix Broken Packages

Fix Broken Packages In Synaptic
Fix Broken Packages In Synaptic

It will take some time if there are broken packages present. Check if the problem is resolved.

References

Summary

In this article, we saw five different methods to fix the error “Unable to correct problems, you have held broken packages.” All the methods discussed were easy to execute and I hope you were able to fix the problem on your system. If you are still facing the same issue even after trying all the above methods, it can be because of using an unsupported Linux distribution, in which case, you will have to consider upgrading to a newer version of it.