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

Solution 1:

sudo apt-get --with-new-pkgs upgrade

Above command will install the “kept back” packages for you .

As per man apt-get

       --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.

Solution 2:

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.

Solution 3:

sudo apt full-upgrade

Or

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.

  1. packages were marked as hold by apt-mark
   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

  1. apt detects 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 --with-new-pkgs.

    This should be most of the cases that we get message “The following packages have been kept back”

  2. Phased updates

    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.

Conclusion

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 .