[FIXED!] apt: The following packages were kept back
A common problem on Linux operating systems is when you run the update command (such as
sudo apt update && sudo apt upgrade) and receive the following output:
The following packages have been kept back: [PACKAGE-NAME] [PACKAGE-NAME] [PACKAGE-NAME]
Here, I will show you how to fix that issue, as well as explain why it happens.
How to solve “The following packages have been kept back”
The way to get the packages that were kept back to install is to simply install them individually. As we’ll soon see, this behavior isn’t actually the result of an error or dependency issue, but is intentional. We can overrride the behavior of not updating certain packages by manually installing them.
In the screenshot above, you can see that the packages
libpam-systemd, and several more were not updated. Let’s install those packages manually:
$ sudo apt install libnss-systemd libpam-systemd libsystemd-shared # And so on. . .
Then, when we run
sudo apt upgrade we can see in the output that there are “0 packages not upgraded.”
$ sudo apt upgrade Reading package lists... Done Building Dependency tree... Done Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded
If the output says something like, “3 packages not upgraded,” that means that the package you installed has dependencies that were kept back in the process of installing that package. Simply repeat the process until there are zero packages not upgraded.
Why were the packages kept back?
It turns out, the holding back of packages is intentional in the design of the Linux operating system, and for a very good reason.
If you have used some of the less stable distributions of Linux such as KDE Neon or Kali Linux, you may have experienced what’s called a regression. A regression occurs when an updated version of a package causes the system to run worse than before, or maybe even crash. Stable Linux distributions such as Ubuntu and Mint don’t commonly have this problem, but there are still safeguards against it.
Most Linux distributions, including Ubuntu, implement something called Phased Updates. With Phased Updates, new versions of packages are initially only pushed to a limited number of users, to limit the number of machines that might be affected by a possible regression. The typical initial push is made to about 10% of all users, and it takes about two days for new updates to reach everyone.
This makes perfect sense when you think about it. Imagine if an updated package caused a regression after the update was pushed to the thousands or millions of machines that run the affected operating system. This would have a devastating impact on both the users of the machines, as well as on the reputation of the developers.
So another option for addressing the “packages have been kept back” message is to simply wait until those updates are made available to you. The developers will have tested the updates for any regressions, so you can be more confident that they will not cause any damage to your system.