How to Fix the “The following packages have been kept back” Error

The packages and software on the Linux Operating System are consistently being changed. To cater to these changes, the system needs to be updated constantly so that various system files and packages do not disturb system functionalities. Oftentimes, while trying to upgrade the system packages, an error “The following packages have been kept back” is encountered.

This article will provide all the necessary knowledge on the reasoning behind this error and how this issue can be resolved in your system.

How to Fix the “The following packages have been kept back” Problem?

There is one main reason that will invoke this error. This section will elaborate on the reasons and demonstrate how this error can be resolved. Let’s dig into them:

Reason: Changed Dependencies

The error mostly occurs when trying to run the following two commands:

$ sudo apt update
$ sudo apt upgrade

During the upgrading part, some of the packages may not be able to upgrade and the error may be prompted as shown in the snippet below:

Sometimes, the dependency of a package is changed so drastically that the current package is no longer able to support it. When this happens, the packages will not be upgraded since their dependency no longer supports that package. For example, the snippet has shown packages whose dependency will no longer allow them to be upgraded. These two packages are “libnftables1” and “nftables”.

Solution: Install the New Package

Since, the error was encountered due to the dependency being upgraded to a point where it no longer supported the updating of the old package, the only fix to this issue is to install the newer packages for it. This can be achieved quite simply by installing the package mentioned in the snippet above using the apt. For example, the above example showed the error for a package named “libnftables1”. So, to install this package run the command shown below:

$ sudo apt install libnftables1

The command will upgrade the package automatically since the older version of this package was already installed on the system. This is demonstrated in the snippet below:

This command upgraded both of the packages that were mentioned in the error prompt. This may not always be the case in which scenario you will have to install both packages separately using this format:

$ sudo apt install (package)

Where the package is the name of the package shown in the error. Through this method, the error will be resolved and all the packages will be upgraded.

Conclusion

The “The following packages have been kept back” problem occurs when the dependencies have been updated where they require new packages to be installed alongside the old ones. This can be fixed by directly installing the packages using the “apt”. Doing this will automatically upgrade the packages. This article has demonstrated the reason behind the error “The following packages have been kept back” and also the solution.