[SOLVED] Unable to correct problems, you have held broken packages

[SOLVED] Unable to correct problems, you have held broken packages

APT is one of the most popular program in Ubuntu/Debian and their derivatives. It's made to handle the installation and removal of packages. Most of the time, the application works flawlessly without any issues. But on rare occasions, you may see "Unable to correct problems, you have held broken packages" error message pops up. This error, along with "apt-get : command not found” are two of the most popular error message when it comes to apt or apt-get in Linux.

This short article is going to show you what cause the "Unable to correct problems, you have held broken packages" error and what you can do to fix it.

"Unable to correct problems, you have held broken packages" error

The error message may look something like this :

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 ffmpeg : Depends: libavcodec58 (= 7:4.1.6-1~deb10u1)
          Depends: libavdevice58 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
          Depends: libavfilter7 (= 7:4.1.6-1~deb10u1)
          Depends: libavformat58 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
          Depends: libavresample4 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
          Depends: libavutil56 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
          Depends: libpostproc55 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
          Depends: libswresample3 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
          Depends: libswscale5 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
E: Unable to correct problems, you have held broken packages.

Linux systems follow Unix design philosophy : Make each program do one thing well. That means a complex program has to rely on smaller ones to do its many small jobs.

For example, the VLC media player needs libavcodec, libavutil, libgles2 and a whole bunch of other packages to be able to work properly. Those small libraries and software components are called dependencies. These dependencies may not be part of the application package itself, but they are expected to either be installed on your system already or installed during the installation of the application.

The "Unable to correct problems, you have held broken packages" error usually comes with other information about which libraries/programs needs to be installed but the system is unable to install them. In the message above, it is python-pip-whl.

The situation may get more complicated when two programs, let's say VLC and Gnome Video Player need different versions of the same library. APT, in that case, cannot figure out how to install both version and raise "Unable to correct problems, you have held broken packages" error.

"Unable to correct problems, you have held broken packages"**

Fix "Unable to correct problems, you have held broken packages" error

There's a few things you can do to get things to work again. Before following the steps below, make sure you know how to interact with the Linux terminal and the APT command.

Update local package index

If you're installing a well-known software, there's a high chance that it was tested thoroughly by the original developers as well as Ubuntu/Debian team before adding to the package directory. In other words, maintainers made sure the software works flawlessly with the system, so updating your local package index is a popular way to get rid of the "broken packages" error.

You can resynchronize the package index files from their sources on Ubuntu via the Internet by running the following command.

sudo apt update

Once the update process is done, try reinstalling the troublesome package again to verify that the error has gone.

Remove left-over packages from your system

Aside from updating package index, removing unused packages from your system usually helps in case you keep encounter "Unable to correct problems, you have held broken packages" error.

Every time you install a program, its dependencies get installed, too. But after you remove the program, some of the dependencies are left over. Those left-over dependencies rely on other programs, and APT needs to keep track of that information, too. APT has an autoremove command that helps clean your system from residual packages.

sudo apt-get autoremove

Try to search and install the dependency again

If you have tried the two solution above but the error message still persist, the dependency may not be available for the distribution version you're running.

You can use apt search to look up the package index for the troublesome dependency.

sudo apt search package_name

If the package is available, inspect it to see whether it's the same version that the system is searching for (specified in the error message). Then, try to install the dependency package and see what happens next.

sudo apt install dependency_package

At this point, you may encounter a dependency chain. Basically, the software A depends on B, then B rely on C, but C is not available for your distribution version.

It may also happen that when you try to install package C, it is already installed. In that case, check the version of package C. Is it the same version as required by package B? If yes, then removing C and installing it again could help.

Directly install from DEB file

If the missing dependency cannot be found by apt search, you may try to install either the package or its dependency directly from a DEB file.

For example, in the apt-get output, you can see that one of the many packages FFMPEG needed is libavcodec58 version 4.1.6-1~deb10u1.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 ffmpeg : Depends: libavcodec58 (= 7:4.1.6-1~deb10u1)
          Depends: libavdevice58 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
          Depends: libavfilter7 (= 7:4.1.6-1~deb10u1)
          Depends: libavformat58 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
          Depends: libavresample4 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
          Depends: libavutil56 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
          Depends: libpostproc55 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
          Depends: libswresample3 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
          Depends: libswscale5 (= 7:4.1.6-1~deb10u1) but 7:4.3.1-6~bpo10+1 is to be installed
E: Unable to correct problems, you have held broken packages.

With this information, you can do a quick Google search or a web-based tool like PKGS.org to find the corresponding DEB file. Once you've downloaded the DEB, install it by running the following command :

sudo dpkg -i libavcodec58_4.1.6-1~deb10u1_amd64.deb

After that, just re-install the troublesome package.

Find another installation source or PPA

If you're trying to install legacy packages, the "Unable to correct problems, you have held broken packages" error wold be raised a lot. In this case, installing individual dependencies can quickly become inconvenient. Your best bet in this situation is to find another installation source, usually a PPA.

Suppose you're trying to install FFMPEG 4, doing a quick search, you would easily find Jonathon F's PPA. You can simply add his PPA to your system before actually re-run apt-get install ffmpeg to install the software.

sudo add-apt-repository ppa:jonathonf/ffmpeg-4
sudo apt-get update
sudo apt-get install ffmpeg

Alternatively, you can try to look for the same software packaged in other formats, such as Snap/Flatpak or AppImage.

If you see the held broken package error during update try this

Most of the solutions above assumed that you see this error while installing a new application. That may not always be the case.

If you see this error when you try updating your system with sudo apt update , you may have to take a slightly different approach.

First, check which package is being held with this command:

dpkg --get-selections | grep hold

If you see any package held back from updating, you can either remove it (sudo apt-get remove) using or unhold it with the following command

sudo apt-mark unhold package_name

The package would be unheld and a confirmation message would be returned : Canceled hold on package_name..

Conclusion

There is no straightforward fix for this problem. You’ll have to investigate the problem on your own and see if the error can be fixed or not. If you find this article helpful, consider checking out our other guide on fixing "apt-get : command not found” - another popular apt-get error message that caused confusion among our readers.

Please share in the comments if your problem gets fixed or not, you will receive the help from us and the community.

Click to rate this post!
[Total: 1 Average: 5]

Leave a Comment