[Solved] “The following packages have been kept back:”
Are you facing the error, “The following packages have been kept back”? Well, that’s frustrating. However, you do not need to worry. We are here with a foolproof guide.
Package management is the key player in Debian and its derivates like other Linux distributions. If the package manager, i.e., apt, apt-get, aptitude, cannot manage the packages, it throws some error messages. One of the errors is “The following packages have been kept back.”
The above-said error message may appear when using package management tools, such as APT (Advanced Package Tool) on Linux-based operating systems or similar package managers like apt-get or aptitude. This message indicates that certain packages still need to be upgraded to their latest versions, even though newer versions are available.
This post will state all the reasons and the possible solutions to eliminate the error. As stated, this error occurs on the Debian/Ubuntu derivates. As an example, we will demonstrate all the steps on Ubuntu 22.04.
How to Fix the “The Following Packages Have Been Kept Back” Error?
The error “following packages are kept” arises for several reasons while using apt/apt-get/aptitude. It can be either dependencies related, updating restrictions, user preferences, etc. It is usually experienced while performing a system upgrade, as shown below:
Before getting into the solutions, let’s elaborate on the reasons first.
Upgrading a package may require updating other packages that depend on it. If these dependent packages are not updated, the package manager may “keep back” the upgrade to avoid breaking dependencies. Let’s understand it more clearly:
If one package (let’s say A) depends on another package (let’s say B), and an upgrade of Package A requires a newer version of Package B. Still, the newer version of Package B is unavailable or has not been installed yet, the upgrade of Package A may be kept back.
The package’s upgrade may result in conflicts with other already installed packages. For example, if two packages provide the same file or functionality and are incompatible, the package manager may keep the upgrade back to avoid conflicts. This can happen when using third-party repositories or when there are discrepancies in the package dependencies.
Some packages may restrict when and how they can be updated. For example, system-related packages critical to operating systems’ functioning may restrict updates to avoid potential system instability. In such cases, the package manager may keep back the upgrade until the restrictions are lifted or resolved.
Package managers allow users to configure preferences and options that can affect package upgrades. For example, users can specify not to install recommended or suggested packages during upgrades or to hold certain packages at specific versions. The package manager may keep back upgrades if such preferences are set.
Solution 1: Manually Upgrade Packages
The primary reason for the error is the dependencies are locked up. To rectify this, look for the held-back packages and then upgrade them individually. Let’s understand it through the following steps:
Step 1: Look for the Held Packages
Check the list of packages that have been kept back using the package manager. For example, with APT, you can use the following command:
$ sudo apt upgrade
The above command’s output has shown that the “gnome-remote-desktop” package is held back.
Step 2: Manually Upgrade Packages
Once the package is identified, use the apt install with the “–only-upgrade” option to upgrade that package individually as we did here:
$ sudo apt install --only-upgrade gnome-remote-desktop
This command will upgrade the packages and their dependencies, allowing the previously kept-back packages to be upgraded.
Once the package is upgraded successfully, you can use the upgrade command again to verify it as follows:
$ sudo apt upgrade
The output shows there are no kept-back packages left.
Solution 2: Wait for Restrictions to be Lifted
Some packages may have update restrictions imposed by the package maintainer or repository. In such cases, waiting until the restrictions are lifted or resolved is best before attempting to upgrade the packages.
Periodically check for updates or announcements from the package maintainer or repository to see if the restrictions have been lifted. Once done, use the following command to upgrade the packages:
$ sudo apt upgrade
Note: If you are still unable to get rid of it, we recommend not manipulating any configuration files to trap yourself. This error does not harm your PC/Laptop. Thus, it is treated more like a flag than a warning/error.
The error message “The following packages have been kept back” can occur in Debian/Ubuntu derivates using package management tools such as apt, apt-get, or aptitude. This error can be caused by various reasons, such as dependencies, pinning, conflicting packages, update restrictions, or user preferences.
To fix this error, you can manually upgrade the held-back packages using the “apt install –only-upgrade” command, which upgrades the packages and their dependencies. Alternatively, you can wait for any update restrictions to be lifted or resolved, as imposed by the package maintainer or repository.
This post has briefly demonstrated the reasons and the possible solutions to fix the error “The following packages have been kept back.”
Visit Linux-Genie for more troubleshooting articles.