install held back packages on debian

5 Best Ways to Force Install Held Back Packages in Debian

Trying to update the software on your Debian device, an annoying “packages have been kept back” error keeps popping up? 

Fret not, as there are a few quick solutions to this.

In this article, we’ll explore the reasons behind this error, plus how you can fix it and successfully update your packages.

Let’s get started!

Why You’ll Need

The requirements to follow this tutorial are as follows:

  • Debian installed and running (guide)
  • Familiarity with the Command Line Interface (CLI) and CLI commands (guide)
  • Root account or sudo privileges (guide)
  • A stable internet connection

If you have everything available, you can continue to the main section, where I show you the fixes. 

Before we proceed with that, let’s see why this problem occurs in the first place, as this gives us a better understanding of the root cause(s).

Why Are Packages Kept Back From Upgrading?

There could be several reasons for this error. Some possible reasons are:

1. Reason: Phased Updates

If there is a new update, it’s not provided to everyone at once. Instead, only some users receive that update. Gradually, all users receive that update after it’s proven to be stable. In other words, that update is now fully phased.

This method of rolling out updates in stages is known as ‘Phased Updates’.

2. Reason: Change in Dependencies

If you have a package installed and need to update it, you may require additional dependencies for the update.

As a result, you may face a “kept back” error when you try to upgrade that package.

3. Reason: It is Marked as Held Back

Did you know that you can mark packages as held back?

To mark a package as held back, use the following command:

sudo apt-mark hold <package name>

Accidentally marking a package like that can stop its update. Thus, to remove a package from being held, you could run the below command:

sudo apt-mark unhold <package name>

How to Force Install Held Back Packages in Debian: Step-By-Step

Method 1: Ignore and Wait

If you’re encountering the “packages kept back” message in Debian due to Phased Updates, this is the simplest solution. 

Just wait for the updates to become available.

In phased updates, only a small random amount of people get the update initially. If you’re not one of those who received the update, then your package(s) won’t be updated. Instead, it will be listed as a held-back package.

When the right time comes, you should receive the update. As a result, the error will eventually go away.

While there’s nothing for you to do in this method, it doesn’t guarantee to fix the problem either. That’s because we’re only assuming this is because of phased updates–what if that’s not the case?

Thus, you can go through the next methods to directly fix the problem.

Method 2: Update the Packages Using install –only-upgrade

The –only-upgrade option is usually used for upgrading a single package. But you can use this to force-update any held-back packages.

  1. First, you need to update your system. Since this problem is about updating in the first place, you’ve probably done that already. If not, update it now so that your package lists have the latest versions available to them:
sudo apt update
sudo apt update
  1. Now, let’s see the packages that you can upgrade. To list those packages, run the following command:
apt list --upgradable
list upgradable applications

This command will list all the packages that are pending an upgrade. In my case, there weren’t any packages, hence the list being empty.

Note: You can also list only the held-back packages. To do that, run the following command: apt-mark showhold. This command will only list the packages that are being kept back from updating.

  1. Lastly, update the package using the install –only-upgrade command. Do that by adding the package name you want to upgrade with the install –only-upgrade command. Follow the below format for that:
sudo apt install --only-upgrade <package names>

Replace <package names> with the packages that were held back from updating on your machine.

Doing this should take care of the packages.

Method 3: Update the Packages Using Aptitude

Aptitude is an APT front-end. You can use this tool to manually upgrade the targeted packages.

Step 1: Install Aptitude on Debian

First, you need to install Aptitude on your system.

  1. Update your system with the following command:
sudo apt update
  1. Then install Aptitude on Debian with this command:
sudo apt install aptitude
install aptitude on debian

Step 2: Upgrade Packages Using Aptitude

With Aptitude successfully installed, let’s use it to deal with the problematic packages.

  1. Run the below command to upgrade. This command handles held packages by installing new packages to resolve dependencies.
sudo aptitude safe-upgrade
safe upgrade using aptitude
  1. Check your package list to see if there are any held-back apps left:
apt-mark showhold

This should fix the problem and update any packages that were not being upgraded previously.

Method 4: Update the Packages Using –with-new-pkgs Option

If the normal upgrade command doesn’t work for you, you can add the –with-new-pkgs command option to solve the issue.

This option tells your system to install any required packages before upgrading the existing packages.

  1. Add the option to the usual upgrade command like this:
sudo apt-get --with-new-pkgs upgrade
  1. Then, add the packages to the command as an argument. The final command will look like this:
sudo apt-get --with-new-pkgs upgrade <package list>
upgrade packages with dependencies on debian

In my case, I didn’t add any packages because none were available to be upgraded. However, in your case, you should add the names of the package(s).

Method 5:  Update the Packages Using dist-upgrade

This should be your last resort.

Why?

Because the ‘dist-upgrade’ command can be risky. It has the potential to install and remove packages, which, if used without proper knowledge, could lead to system instability. 

With that in mind, let’s see how it works.

  1. Simply run the following command:
sudo apt-get dist-upgrade

Once again, this method is risky, but it can solve the kept-back package problem. 

Conclusion

This guide shows you multiple methods of force-installing and updating held-back packages on Debian. 

Depending on why this is happening in your case, you can choose from any of the methods.

Interested to learn more about handling packages in Linux?

Check out our guides on blocking packages or reconfigure them.

If this guide helped you, please share it.

Related Posts