I just added a PPA repository for the development version of the GIMP, but I get this error:
$ apt-get update && apt-get upgrade
...
The following packages have been kept back:
gimp gimp-data libgegl-0.0-0 libgimp2.0
Why and how can I solve it so that I can use the latest version instead of the one I have now?
According to an article on debian-administration.org,
Cautious solution 1:
Per Pablo's answer, you can run
sudo apt-get --with-new-pkgs upgrade
, and it will install the kept-back packages.This has the benefit of not marking the kept-back packages as "manually installed," which could force more user intervention down the line (see comments).
If Pablo's solution works for you, please upvote it. If not, please comment what went wrong.
Cautious solution 2:
The cautious solution is to run
sudo apt-get install <list of packages kept back>
. In most cases this will give the kept-back packages what they need to successfully upgrade.Aggressive solution:
A more aggressive solution is to run
sudo apt-get dist-upgrade
, which will force the installation of those new dependencies.But
dist-upgrade
can be quite dangerous. Unlike upgrade it may remove packages to resolve complex dependency situations. Unlike you, APT isn't always smart enough to know whether these additions and removals could wreak havoc.So if you find yourself in a place where the "cautious solution" doesn't work,
dist-upgrade
may work... but you're probably better off learning a bit more about APT and resolving the dependency issues "by hand" by installing and removing packages on a case-by-case basis.Think of it like fixing a car... if you have time and are handy with a wrench, you'll get some peace of mind by reading up and doing the repair yourself. If you're feeling lucky, you can drop your car off with your cousin
dist-upgrade
and hope she knows her stuff.Whenever you receive from the command
apt-get upgrade
the messagethen to upgrade one or all of the kept-back packages, without doing a distribution upgrade (this is what
dist-upgrade
does, if I remember correctly) is to issue the command:this will resolve the kept-back issues and will ask to install additional packages, etc. as was explained by other answers.
See also: Why use apt-get upgrade instead of apt-get dist-upgrade?
I answered a similar question here, explaining a bit more about the reasons behind this issue.
Try this Unix SE answer:
apt
command (friendly alternative toapt-get
) share this option.Using
apt install <pkg>
instead will mark pkg as "manually installed"!! To mark it again as "automatically installed" useapt-mark auto <pkg>
(see also subcommandshowmanual
). More info on this answer.apt-get dist-upgrade
is dangerous for stable environment,Use case: kernel upgrade kept back, you just want to upgrade the kernel, dont want to upgrade entire distribution.
Better way to handle kept back package:
If you have kept back package you should see Upgradable Packages on top of the list.
Your kept back package installed.
There are normally two reasons you may see this message.
If upgrading the program (via
sudo apt-get upgrade
) would cause packages to be added or removed, then the program will be held back. You can usesudo apt-get dist-upgrade
in this case, which will then offer to add or remove the additional packages.This is pretty common and usually not an issue. Occasionally (particularly during an Ubuntu alpha) a
dist-upgrade
will offer to remove a lot of other programs, in which case you probably want to cancel it.If the package depends on packages or versions that are not available, then the program will be held back. You really can't do anything but wait in this circumstance, since the package is basically uninstallable. This can happen when packages get added to the repository out of order, when a package is renamed, or when a package stops providing a virtual package.
You can also try aptitude. First install it:
then:
It's safer than
full-upgrade
(originally nameddist-upgrade
) because "packages will not be removed unless they are unused".From
man aptitude
:Most likely these packages are held back because their installation would create dependency inconsistencies. This can either happen because you are using archives under active development, ppas, or because the mirror you uses is not fully updated.
In the last case, just wait, when the dependencies are resolved it will be installed the next time.
Edit:
There is another possibility, packages might be held back if there is put a hold on them, or if they are pinned.
Ubuntu 18.04, 20.04, 22.04, … provide a streamlined syntax via
apt full-upgrade
which functions likesudo apt-get dist-upgrade
.Note:
full-upgrade
remains on the current distribution.See:
apt
man page: 18.04, 20.04, 22.04This worked for me
I'm adding this answer because I'm not satisfied with how other answers handle the why part of the question to understand what's going on and choose the appropriate course of action.
Hopefully this will help someone avoid blindly running
apt dist-upgrade
in despair!Why is a package kept back?
To my knowledge, there are 2 categories of reasons for packages being kept back during
apt upgrade
.It is marked as held back
apt-mark
can do this:To list all packages marked on hold or find out if a package is on hold use:
To remove a hold on a package and allow it to be upgraded:
apt
detects a dependency changeThe best authoritative source of information I could find regarding this is marked as obsolete, but it says:
This will tell you the current and candidate upgrade versions of the package:
With the current version (e.g.
2:8.0.1453-1ubuntu1.3
) and new version (e.g.2:8.0.1453-1ubuntu1.4
), we can figure out the changed dependencies withapt show
:(or just use
apt show -a
to view all versions directly, but it makes the version comparison harder in my opinion)The important parts are the
Depends
andRecommends
package lists. If there are new packages in those lists in the new version of the kept back package, apt won't automatically upgrade it.At this point there are 2 options to upgrade the kept back package. Note that both solutions below have the proper arguments to avoid erroneously changing a package from "automatically installed" to "manually installed".
To upgrade the package and install any new "Recommended" packages (i.e. as if newly installed with
apt install <package>
, use--only-upgrade
:(Tip: add
--dry-run
to see what will happen before doing it)To upgrade the package without installing any newly added "Recommended" packages, use
--with-new-pkgs
.Case study: upgrading the
docker-ce
packageUpgrading the
docker-ce
package on Ubuntu 18.04 is what brought me here in the first place so I thought it would be interesting to have a full concrete example.Ok let's see what's holding back
docker-ce
:Version
5:20.10.3~3-0~ubuntu-bionic
has addeddocker-ce-rootless-extras
as a new recommended dependency. I wish apt would be more helpful and simply suggest installing it or something instead of leaving me with an old version... Anyhow, here are the 2 possible fixes (with--dry-run
for illustration purposes):