In Ubuntu 22.04 , when we run command
sudo apt upgrade or
sudo apt-get uprade , it’s possible to get below error which means some of the packages can’t be upgraded .If so you can choose one of solutions listed below to fix it.
The following packages have been kept back
sudo apt-get --with-new-pkgs upgrade
Above command will install the “kept back” packages for you .
--with-new-pkgs Allow installing new packages when used in conjunction with upgrade. This is useful if the update of an installed package requires new dependencies to be installed. Instead of holding the package back upgrade will upgrade the package and install the new dependencies. Note that upgrade with this option will never remove packages, only allow adding new ones. Configuration Item: APT::Get::Upgrade-Allow-New.
sudo apt-get install <the "kept back" package>
Using this command you can upgrade one of or all the
kept back packages , it will ask you that additional packages will be installed.
sudo apt full-upgrade
sudo apt-get dist-upgrade
In case both solution 1 and solution 2 don’t fix the issue for you , you can try this method. But please be careful because this command will do some remove actions as required .
dist-upgrade dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. The dist-upgrade command may therefore remove some packages. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the general settings for individual packages.
Wait , but why
You may also are curious on why this issue happened , below are few of the possibilities.
- packages were marked as
sudo apt-mark hold <package>
This command can be used to mark a package as held back, which will prevent the package from being automatically installed, upgraded or removed
aptdetects dependency issue
Which means the upgrade also needs to install some new dependencies , and by default package will be in “kept back” status . To install the dependent packages also , we can add option
This should be most of the cases that we get message “The following packages have been kept back”
Once an update is released to -updates, the update is then phased so that the update is gradually made available to expanding subsets of Ubuntu users.
For the “kept back” issue , we have several solutions , excepts the 3 mentioned here , maybe also there are other solutions. Anyway hope this page can help you to fix this issue .