SnapOverflow

SnapOverflow Logo SnapOverflow Logo

SnapOverflow Navigation

  • Home
  • Server
  • Ubuntu

Mobile menu

Close
  • Home
  • System Administrators
    • Hot Questions
    • New Questions
    • Tags
  • Ubuntu
    • Hot Questions
    • New Questions
    • Tags
  • Help
Home / ubuntu / Questions / 601
Accepted
jfoucher
jfoucher
Asked: 2010-08-01 13:59:22 +0800 CST2010-08-01 13:59:22 +0800 CST 2010-08-01 13:59:22 +0800 CST

"The following packages have been kept back:" Why and how do I solve it?

  • 772

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?

package-management apt
  • 26 26 Answers
  • 1271599 Views

26 Answers

  • Voted
  1. Best Answer
    crenshaw-dev
    2010-08-01T14:15:04+08:002010-08-01T14:15:04+08:00

    According to an article on debian-administration.org,

    If the dependencies have changed on one of the packages you have installed so that a new package must be installed to perform the upgrade then that will be listed as "kept-back".

    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.

    • 1558
  2. user88285
    2012-09-09T01:14:42+08:002012-09-09T01:14:42+08:00

    Whenever you receive from the command apt-get upgrade the message

    The following packages have been kept back:
    

    then 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:

    apt-get install <list of packages kept back>
    

    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?

    • 612
  3. Pablo Bianchi
    2016-12-21T12:16:32+08:002016-12-21T12:16:32+08:00

    I answered a similar question here, explaining a bit more about the reasons behind this issue.


    Try this Unix SE answer:

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

    This allows new packages to be installed. It will let you know what packages would be installed and prompt you before actually doing the install.

    apt command (friendly alternative to apt-get) share this option.

    Using apt install <pkg> instead will mark pkg as "manually installed"!! To mark it again as "automatically installed" use apt-mark auto <pkg> (see also subcommand showmanual). More info on this answer.

    • 340
  4. mudy
    2010-12-24T16:43:16+08:002010-12-24T16:43:16+08:00

    apt-get dist-upgrade is dangerous for stable environment,

    1. wrong source.list setting and you end up with broken ubuntu.
    2. you might get entire application upgraded to version you dont want.

    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:

    sudo aptitude
    

    If you have kept back package you should see Upgradable Packages on top of the list.

    • Hit + on that list
    • Hit g twice
    • Answer debconf stuff if asked
    • Press return to continue
    • Press Q
    • Press yes

    Your kept back package installed.

    • 191
  5. jbowtie
    2010-08-01T14:16:48+08:002010-08-01T14:16:48+08:00

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

    • 41
  6. Afilu
    2014-08-13T00:02:22+08:002014-08-13T00:02:22+08:00

    You can also try aptitude. First install it:

    sudo apt-get install aptitude -y
    

    then:

    sudo aptitude safe-upgrade
    

    It's safer than full-upgrade (originally named dist-upgrade) because "packages will not be removed unless they are unused".

    From man aptitude:

    safe-upgrade

    Upgrades installed packages to their most recent version. Installed packages will not be removed unless they are unused [...] Packages which are not currently installed may be installed to resolve dependencies unless the --no-new-installs command-line option is supplied.

    • 38
  7. txwikinger
    2010-08-01T14:17:03+08:002010-08-01T14:17:03+08:00

    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.

    • 26
  8. l --marc l
    2019-07-30T06:05:06+08:002019-07-30T06:05:06+08:00

    Ubuntu 18.04, 20.04, 22.04, … provide a streamlined syntax via apt full-upgrade which functions like sudo apt-get dist-upgrade.

    sudo apt full-upgrade
    

    sudo apt upgrade is used to install available upgrades of all packages currently installed on the system from the sources configured via sources.list(5). New packages will be installed if required to satisfy dependencies, but existing packages will never be removed. If an upgrade for a package requires the remove of an installed package the upgrade for this package isn't performed.

    sudo apt full-upgrade performs the function of upgrade but will remove currently installed packages if this is needed to upgrade the system as a whole.

    Note: full-upgrade remains on the current distribution.

    See: apt man page: 18.04, 20.04, 22.04

    • 22
  9. Singh
    2013-03-23T03:40:43+08:002013-03-23T03:40:43+08:00

    This worked for me

    sudo aptitude full-upgrade
    
    • 19
  10. bernie
    2021-02-15T06:21:14+08:002021-02-15T06:21:14+08:00

    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:

    sudo apt-mark hold <package>
    

    hold is used to mark a package as held back, which will prevent the package from being automatically installed, upgraded or removed.

    To list all packages marked on hold or find out if a package is on hold use:

    apt-mark showhold
    apt-mark showhold <package>
    

    To remove a hold on a package and allow it to be upgraded:

    sudo apt-mark unhold <package>
    

    apt detects a dependency change

    The best authoritative source of information I could find regarding this is marked as obsolete, but it says:

    [Kept back] means that there are new versions of these packages which will not be installed for some reason. Possible reasons are broken dependencies (a package on which it depends doesn't have a version available for download) or new dependencies (the package has come to depend on new packages since the last version)

    This will tell you the current and candidate upgrade versions of the package:

    $ apt list <package>
    
    # example output:
    vim/bionic-updates,bionic-security 2:8.0.1453-1ubuntu1.4 amd64 [upgradable from: 2:8.0.1453-1ubuntu1.3]
    N: There are 2 additional versions. Please use the '-a' switch to see them.
    

    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 with apt show:

    apt show <package>=<old version> <package>=<new version>
    
    # example:
    apt show vim=2:8.0.1453-1ubuntu1.3 vim=2:8.0.1453-1ubuntu1.4
    

    (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 and Recommends 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".

    1. To upgrade the package and install any new "Recommended" packages (i.e. as if newly installed with apt install <package>, use --only-upgrade:

      sudo apt install --only-upgrade <package>
      

      (Tip: add --dry-run to see what will happen before doing it)

    2. To upgrade the package without installing any newly added "Recommended" packages, use --with-new-pkgs.

      sudo apt upgrade --with-new-pkgs <package>
      

    Case study: upgrading the docker-ce package

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

    $ sudo apt upgrade
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Calculating upgrade... Done
    The following packages have been kept back:
      docker-ce
    0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
    
    $ apt list docker-ce
    Listing... Done
    docker-ce/bionic 5:20.10.3~3-0~ubuntu-bionic amd64 [upgradable from: 5:19.03.12~3-0~ubuntu-bionic]
    N: There are 34 additional versions. Please use the '-a' switch to see them.
    

    Ok let's see what's holding back docker-ce:

    $ apt show docker-ce=5:19.03.12~3-0~ubuntu-bionic docker-ce=5:20.10.3~3-0~ubuntu-bionic
    Package: docker-ce
    Version: 5:19.03.12~3-0~ubuntu-bionic
    Priority: optional
    Section: admin
    Maintainer: Docker <[email protected]>
    Installed-Size: 107 MB
    Depends: docker-ce-cli, containerd.io (>= 1.2.2-3), iptables, libseccomp2 (>= 2.3.0), libc6 (>= 2.8), libdevmapper1.02.1 (>= 2:1.02.97), libsystemd0
    Recommends: aufs-tools, ca-certificates, cgroupfs-mount | cgroup-lite, git, pigz, xz-utils, libltdl7, apparmor
    Conflicts: docker (<< 1.5~), docker-engine, docker-engine-cs, docker.io, lxc-docker, lxc-docker-virtual-package
    Replaces: docker-engine
    Homepage: https://www.docker.com
    Download-Size: 22.5 MB
    APT-Manual-Installed: yes
    APT-Sources: https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
    Description: Docker: the open-source application container engine
     Docker is a product for you to build, ship and run any application as a
     lightweight container
     .
     Docker containers are both hardware-agnostic and platform-agnostic. This means
     they can run anywhere, from your laptop to the largest cloud compute instance and
     everything in between - and they don't require you to use a particular
     language, framework or packaging system. That makes them great building blocks
     for deploying and scaling web apps, databases, and backend services without
     depending on a particular stack or provider.
    
    Package: docker-ce
    Version: 5:20.10.3~3-0~ubuntu-bionic
    Priority: optional
    Section: admin
    Maintainer: Docker <[email protected]>
    Installed-Size: 121 MB
    Depends: containerd.io (>= 1.4.1), docker-ce-cli, iptables, libseccomp2 (>= 2.3.0), libc6 (>= 2.8), libdevmapper1.02.1 (>= 2:1.02.97), libsystemd0
    Recommends: apparmor, ca-certificates, docker-ce-rootless-extras, git, libltdl7, pigz, xz-utils
    Suggests: aufs-tools, cgroupfs-mount | cgroup-lite
    Conflicts: docker (<< 1.5~), docker-engine, docker-engine-cs, docker.io, lxc-docker, lxc-docker-virtual-package
    Replaces: docker-engine
    Homepage: https://www.docker.com
    Download-Size: 24.8 MB
    APT-Sources: https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
    Description: Docker: the open-source application container engine
     Docker is a product for you to build, ship and run any application as a
     lightweight container
     .
     Docker containers are both hardware-agnostic and platform-agnostic. This means
     they can run anywhere, from your laptop to the largest cloud compute instance and
     everything in between - and they don't require you to use a particular
     language, framework or packaging system. That makes them great building blocks
     for deploying and scaling web apps, databases, and backend services without
     depending on a particular stack or provider.
    

    Version 5:20.10.3~3-0~ubuntu-bionic has added docker-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):

    $ sudo apt upgrade --with-new-pkgs --dry-run docker-ce
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Calculating upgrade... Done
    The following packages will be upgraded:
      docker-ce
    1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Inst docker-ce [5:19.03.12~3-0~ubuntu-bionic] (5:20.10.3~3-0~ubuntu-bionic Docker CE:bionic [amd64])
    Conf docker-ce (5:20.10.3~3-0~ubuntu-bionic Docker CE:bionic [amd64])
    
    $ sudo apt install --only-upgrade --dry-run docker-ce
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following additional packages will be installed:
      docker-ce-rootless-extras
    Recommended packages:
      slirp4netns
    The following NEW packages will be installed:
      docker-ce-rootless-extras
    The following packages will be upgraded:
      docker-ce
    1 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Inst docker-ce [5:19.03.12~3-0~ubuntu-bionic] (5:20.10.3~3-0~ubuntu-bionic Docker CE:bionic [amd64])
    Inst docker-ce-rootless-extras (5:20.10.3~3-0~ubuntu-bionic Docker CE:bionic [amd64])
    Conf docker-ce (5:20.10.3~3-0~ubuntu-bionic Docker CE:bionic [amd64])
    Conf docker-ce-rootless-extras (5:20.10.3~3-0~ubuntu-bionic Docker CE:bionic [amd64])
    
    • 18

Sidebar

Stats

  • Questions 681965
  • Answers 980273
  • Best Answers 280204
  • Users 287326
  • Popular
  • Answers
  • Marko Smith

    How to add a directory to the PATH?

    • 17 Answers
  • Marko Smith

    How do I install .run files?

    • 7 Answers
  • Marko Smith

    How to list all installed packages

    • 24 Answers
  • Marko Smith

    How do I get the CPU temperature?

    • 21 Answers
  • Marko Smith

    Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?

    • 25 Answers
  • Marko Smith

    How can I add a user as a new sudoer using the command line?

    • 7 Answers
  • Marko Smith

    Change folder permissions and ownership

    • 9 Answers
  • Marko Smith

    How do you restart Apache?

    • 13 Answers
  • Marko Smith

    How can I uninstall software?

    • 11 Answers
  • Marko Smith

    How can PPAs be removed?

    • 26 Answers
  • Martin Hope
    justingrif How to add a directory to the PATH? 2009-07-23 12:42:23 +0800 CST
  • Martin Hope
    NES How to enable or disable services? 2010-12-30 13:03:32 +0800 CST
  • Martin Hope
    Ivan How to list all installed packages 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra Unable to lock the administration directory (/var/lib/dpkg/) is another process using it? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    Olivier Lalonde How to keep processes running after ending ssh session? 2010-10-22 04:09:13 +0800 CST
  • Martin Hope
    David B How can I add a user as a new sudoer using the command line? 2010-10-16 04:02:45 +0800 CST
  • Martin Hope
    Hans How do I remove old kernel versions to clean up the boot menu? 2010-08-21 19:37:01 +0800 CST
  • Martin Hope
    David Barry How do I determine the total size of a directory (folder) from the command line? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher "The following packages have been kept back:" Why and how do I solve it? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford How can PPAs be removed? 2010-07-30 01:09:42 +0800 CST

Related Questions

Trending Tags

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • Home
  • Questions
    • Hot Questions
    • New Questions
  • Tags
  • Help

Footer

SnapOverflow

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Help

© 2022 SOF-TR. All Rights Reserve