1696

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?

jfoucher
  • 23,534
  • 20
    Staggered releases are a safety feature called "Phased Updates." – Louis Waweru Aug 09 '22 at 09:14
  • 7
    @AndrewKoster: or, tell us why it's not, yeah? That'd be helpful. Phased Updates does seem to have been the answer for me, though. See also: https://wiki.ubuntu.com/PhasedUpdates ... additionally, apt show <package>=<new-version> (where <package> is one of the packages listed in apt list --upgradable and <new-version> is the version string listed as the 2nd (space-separated) field in the output of same) should show a line saying Phased-Update-Percentage: <n> for some <n> that's the current percentage. Presumably once that gets to 100%, one will get the upgrade. – lindes Sep 17 '22 at 17:15
  • 4
    P.S. I found this helpful (in zsh or bash): apt show -a $(apt list --upgradable 2>&1 | grep / | cut -d/ -f1) 2>&1 | grep Phased | sort -n | uniq -c -- shows how many packages are at what phased-update percentages. (e.g. I currently have 3 at 0%, and 14 at 70%). – lindes Sep 17 '22 at 17:17
  • 3
    To save everyone a lot of time reading, I recommend looking at Afilu's answer first. – Brōtsyorfuzthrāx Sep 27 '22 at 01:50
  • If everything is working fine in the system regardless of some packages being held back, is it really necessary to "fix" this "warning"? Some will be fixed eventually by doing apt update in the long run, and some new others will appear as held back. But if it does not affect the system negatively, would there be a reason to "fix" this excluding getting rid of the warning? – M.K Feb 08 '23 at 14:38
  • I wonder what I said here that was so toxic that it got moderated away? LMAO – Andrew Koster Nov 16 '23 at 21:36
  • @M.K "eventually" may simply not be soon enough for a security update, depending on one's use case. – Ron Kaminsky Mar 08 '24 at 17:12

29 Answers29

1957

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

(Note that this is not the only reason that you may be seeing the message "packages have been kept back". Another reason is that phased updates may be enabled, and the updates have not yet been released for your machine.)

Cautious solution 1:

Per Pablo's answer, you can run sudo apt-get --with-new-pkgs upgrade <list of packages kept back>, 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.

Flimm
  • 41,766
crenshaw-dev
  • 31,762
  • 237
    As this is an accepted answer needs, it really needs updating to warn about using dist-upgrade on a stable system as many of the other answers below have pointed out. Personally I think there is a simpler/safer answer that needs promoted: apt-get install – Cas Oct 03 '12 at 12:41
  • 13
    Cas, should I just add that it could be dangerous to run a dist-upgrade on a stable system? Why exactly is that dangerous? (I honestly don't know apt all that well.) – crenshaw-dev Oct 03 '12 at 16:27
  • 26
    There is a Server Fault answer that explains dist-upgrade in a bit more detail. I think its just worth clarifying (not dangerous as such) that it may upgrade the entire system which may be beyond what the user expects/wants i.e. in the OP example they are wondering why gimp is being held back. – Cas Oct 05 '12 at 16:38
  • 25
    Please note that sudo apt-get dist-upgrade can also remove packages. Consequently, it's best always to inspect the list of changes that will be made before agreeing to them, when running sudo apt-get dist-upgrade. – Eliah Kagan Mar 22 '13 at 13:56
  • 1
    I've extended the note warning that dist-upgrade is dangerous. I'm not very satisfied with what I've written. But I want a much more emphatic warning – Aaron McDaid Jul 10 '15 at 12:44
  • i had to use dist-upgrade to resume a failed release-upgrade the release-upgrade failed because of a previously broken package and after fixing that problem the only way to resume the remaining package upgrade was via dist-upgrade – DevZer0 Sep 30 '15 at 15:04
  • 12
    @EliahKagan May I add that even apt-get upgrade can remove packages? It will always do that when there would be a version conflict otherwise. Think of llvm3.6 vs. llvm3.6v5 (with the "v5" meaning that it was compiled with gcc 5). These two cannot co-exist, only either of both can be kept on the system. So yes dist-upgrade may remove some packages as well, but it's not only dist-upgrade that would do this; under certain circumstances, upgrade would, as well. – syntaxerror Oct 12 '15 at 15:58
  • 1
    If you tried dist-upgrade and some packages are still "kept back", you can try diagnosing the issue with sudo apt-get install <package>; you may find that it is failing because some dependencies are unresolvable (which dist-upgrade alone apparently will not tell you) –  Jan 08 '16 at 20:22
  • 4
    The graphical tool that offers you to upgrade your computer software that appears every day there are new software available... does an apt-get dist-upgrade every single time. It has nothing to do with upgrading to a new version of the OS (i.e. going from 12.04 to 14.04). It is more a form of distinction between kernel upgrades and other upgrades. In any event, you always want to do a dist-upgrade unless you need to keep running with some old version of software. – Alexis Wilke May 20 '16 at 06:12
  • 4
    There is less dangerous option, which does not need listing every package manually: sudo apt-get --with-new-pkgs upgrade from http://unix.stackexchange.com/questions/38837/what-does-the-following-packages-have-been-kept-back-mean – geekQ Dec 12 '16 at 14:25
  • I just attempted to upgrade from 14.04LTS to 16.04LTS. somehow i just got scared that i was lagging behind. so, if we can't upgrade smoothly, i wonder whats the point of keeping our systems. I wonder whether its advizeable tostay on LTS. – nyxee Aug 19 '17 at 00:23
  • 1
    @mac9416, you said "Think of it as upgrading from Ubuntu 12.04 to 14.04". Do you mean this literally? Will sudo apt-get dist-upgrade change which release of Ubuntu I am using? – dinosaur Sep 05 '17 at 20:46
  • @dinosaur it was a confusing analogy, so I edited it out. dist-upgrade does not change the release, because your sources.list files do not change. This answer should help you out. – crenshaw-dev Sep 05 '17 at 21:19
  • 2
    apt-get install will also mark packages as manually installed, you may not want that. They wont un-install when you remove the package that depends on them. – ctrl-alt-delor Oct 07 '17 at 11:03
  • 3
    @syntaxerror Sorry, I just saw this. What you've described is precisely the situation where one must use dist-upgrade. Running apt-get upgrade does not remove packages. As the apt-get manual page says in the description of the upgrade action: "Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed." So dist-upgrade is categorically more powerful than upgrade. – Eliah Kagan Oct 19 '17 at 11:20
  • FYI, I tried the "cautious" method, apt-get install, and because i'm explicitly teling it to install a certain package, apt feels justified to remove others... You do get a chance to say "no, lets not go that way". I got into this mess with an apt-get autoremove that removed a "no longer necessary" package and now two packages are "kept back" and upgrading either will remove 12-15 other packages. Odd. – rew Feb 12 '18 at 13:35
  • @rew the plot thickens. this comment agrees apt-get install removes packages. I'm honestly stumped now which is the "safer" solution. – crenshaw-dev Feb 12 '18 at 20:15
  • The first “cautious” option, will also mark packages as manually installed. This may have a detrimental affect when installing another package that depends on them. E.g. You did apt install games then one day pingus is held back, so you do the fix, then next week you do apt remove games. But pingus will not be removed, as it was manually installed. – ctrl-alt-delor May 02 '18 at 09:16
  • @ctrl-alt-delor is there a scenario where that "sticky" package will cause other (truly damaging) package management issues? Or does it just add the inconvenience of having to run an additional apt remove pingus to force the removal of that package? – crenshaw-dev May 02 '18 at 12:10
  • @mac9416 Probably not. Let me have a go at a scinario. What if it was a library, then it caused you to remove some library by mistake. – ctrl-alt-delor May 02 '18 at 17:07
  • 1
    Installing the kept package helped me also with open-vm-tools. Thank you for the solution and explanation. – Markus Zeller Jun 18 '18 at 18:53
  • @ctrl-alt-delor I feel like that's solved by just keeping an eye on the list of packages to be removed when you manually uninstall (for example) pingus. – crenshaw-dev Jun 18 '18 at 18:56
  • @mac9416 if you want to do the job of apt, then you can do this. However I am not a computer, so I let apt manage my dependencies. – ctrl-alt-delor Jun 18 '18 at 18:58
  • @ctrl-alt-delor if you're upgrading "kept-back" packages, you're already dabbling in the role of "human package manager" by altering its default behavior. – crenshaw-dev Jun 18 '18 at 19:32
  • 1
    @mac9416 this answer https://askubuntu.com/a/862799/10473 is better. Dabble as little as possible. The argument that I dabbled a little, so I dabble a lot, is not valid. If you are just trying to legitimise your own dabbling, by telling others to do like wise, then please realise that you are legitimate and loved. You can do what ever you want on your own system. – ctrl-alt-delor Jun 19 '18 at 11:47
  • @ctrl-alt-delor, that does look like a better solution. I'll edit to point folks further down the page. – crenshaw-dev Jun 19 '18 at 11:52
  • I wonder if some of those actions in ubuntu LTS would break the LTS guaranty. – yucer Oct 04 '20 at 19:11
  • First solution doesn't work at all, it just does nothing then says again "following packages have been kept back..." – sovemp May 04 '21 at 16:58
  • I think something might have changed about the mechanism, because for me, dist-upgrade actually did nothing and it was the regular install command that asked me to remove the :i386 version of a package. Luckily, apt reports in detail what packages it affects and so I could successfully update the package that was being held back. – DaVince May 12 '21 at 06:15
  • 1
    In my case even dist-upgrade didn't do anything (at least it didn't do any damage). I had to use both "Cautious solution #1" and "Cautious solution #2" in that sequence. – Andyc Oct 21 '21 at 06:03
  • "Unlike you, APT isn't always smart enough to know whether these additions and removals could wreak havoc." I've been using Ubuntu for 10+ years and I still don't know what 90% of the packages do when I update/upgrade, which is why I rely on the package manger. I have no idea what's using libsmbclient or libfreerdp-client2-2:amd64 or bamfdaemon is doing. I've come to this answer many times and been frustrated by the warning of dist-upgrade, which I always considered to be safe. – geneorama Nov 29 '21 at 17:18
  • 1
    @geneorama very fair criticism. 12+ years after writing this answer, I'm so far removed from APT internals that I'm not super confident in what's written there. Unless an APT developer can hop in and make authoritative edits (or someone w/ good references), I'm inclined to leave the answer as-is, especially since the "warn about dist-upgrade comment has 208 upvotes. But I share your frustration with the aggressive warning having so little to support it. – crenshaw-dev Nov 29 '21 at 19:33
  • 1
    @MichaelCrenshaw For the records, I appreciate your wonderful answer and follow up comments. Your first suggestion of installing the packages solved my "kept back" issue this time, but I know it hasn't in the past. I've installed R a dozen different ways, and I get this kept back thing often. I've also run dist-upgrade without obvious issue for about 10 years now. I still feel like a Linux Noob and I try to keep my important files in the cloud where they're safe from me. – geneorama Nov 30 '21 at 16:18
  • 3
    sudo aptitude safe-upgrade works, while --with-new-pkgs upgrade does nothing, and the other options are not ideal for other reasons. – endolith Jul 30 '22 at 16:26
  • 2
    sudo apt-get dist-upgrade is the one giving this message, so that's not a solution. This does not work either udo apt-get --with-new-pkgs upgrade so only installing a package worked – Vincent Gerris Aug 09 '22 at 07:50
  • 2
    When --with-new-pkgs doesn't works, apt install --only-upgrade <package_name> can be a solution and won’t mark the package as manually installed as normal install would. – Loïc G. Sep 16 '22 at 16:50
  • 1
    On Debian 11 (bullseye), I used the Cautious Solution 1, followed by repeated sudo apt update and sudo apt upgrade commands (one of which was a sudo apt autoremove) - things went smoothly. – qxotk Sep 18 '22 at 16:58
  • Isn't dist-upgrade for upgrading your Ubuntu version (not for upgrading software on the current one)? – Brōtsyorfuzthrāx Sep 27 '22 at 01:45
  • sudo apt-get install <list of packages kept back> did it for me. Thanks! – ttt Oct 20 '22 at 15:31
  • used @GregorySmitherman 's solution: https://superuser.com/a/1263445/244653 for Ubuntu 22.04.1 – abc Jan 11 '23 at 07:58
  • 1
    If someone finds this result in 2340, I would like to advise them NOT to force update their airlock controller or fusion reactor services with this technique. Let the phased updates do it carefully. – doug65536 Mar 21 '23 at 22:08
  • Even dist-upgrade was not installing the packages for me so I used install with the list of skipped packages. – pratnala Apr 13 '23 at 01:57
  • In the context of a brand-new spun VM, should we go the "unsafe" route to get all the latest release versions, with dist-upgrade -y? – Max Cascone Feb 20 '24 at 19:30
687

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?

Pablo Bianchi
  • 15,657
user88285
  • 6,927
  • 5
    When packages are kept back this way and I manually apt-get upgrade <list of packages>, if I redo apt-get upgrade, it will list the packages in question as no longer required and that I can use apt autoremove to remove them, which I do, and then one last apt-get upgrade and they are no longer listed as kept back... Very weird. Any thoughts? – cram2208 May 16 '17 at 14:31
  • Does apt-get install also remove packages when necessary to resolve gnarly dependency situations, or would you have to run a separate apt-get remove command to accomplish that part of the upgrade process? – crenshaw-dev Sep 05 '17 at 21:23
  • 1
    @cram2208 I believe that's the expected behaviour. The packages that were "automatically installed and [...] no longer required" are the previous versions of the upgraded packages, which are now no longer needed. apt autoremove then removes these unused dependencies. – Alex Sep 07 '17 at 00:56
  • 5
    If the upgrade would require a new package to be installed, the package will be "kept back." First consider using: sudo apt-get --with-new-pkgs upgrade which would not have side affect of causing packages to be marked as manually installed – marc-medley Dec 06 '17 at 21:59
  • @mac9416 yes it does. – jarno Jan 26 '18 at 18:04
  • @mac9416 see e.g. https://askubuntu.com/a/818101/21005 – jarno Jan 26 '18 at 20:13
  • @jarno this leaves me to wonder what the difference between install and dist-upgrade truly is. Thanks for the heads-up. – crenshaw-dev Jan 26 '18 at 23:44
  • @mac9416 apt-get dist-upgrade decides which packages it will upgrade and may keep back packages. With apt-get install you have to name those packages expect maybe when using --fix-broken option. – jarno Jan 28 '18 at 14:24
  • @jarno well that's fair. I meant more in terms of how they handle un-installation of packages. Say you do an apt-get upgrade and packages foo and bar are held back. Previously I'd believed that apt-get install foo bar would upgrade the packages, but only if it didn't have to un-install anything to resolve dependencies; whereas apt-get dist-upgrade would upgrade the packages, uninstalling anything necessary to resolve dependencies. But now it seems as if they are both willing to un-install things. – crenshaw-dev Jan 29 '18 at 14:33
  • @mac9416 Use --no-remove with apt-get if you do not want to remove packages. – jarno Jan 29 '18 at 16:49
  • I have a strong opinion that it should be possible to force the release upgrade anyway. For example I have installed conky 1.11.3 because in 1.11.4 they introduced reparsing of lua-conky-parse expressions what makes it unusable. It seems they don't want to fix it: https://github.com/brndnmtthws/conky/issues/967

    And I defenetly don't want to upgrade it - I set it to kept back manually.

    – iRaS Jul 12 '21 at 13:34
  • This is the only answer that works and doesn't require a full distro upgrade. – Andrew Koster Oct 11 '21 at 20:38
458

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.

Pablo Bianchi
  • 15,657
  • 39
    +1 because it does not have side affect of causing packages to be marked as manually installed. – ctrl-alt-delor Oct 07 '17 at 11:05
  • 5
    Note to who ever reads my comment above: not having the side effect of marking as manually installed is a good thing. I like this answer. – ctrl-alt-delor May 02 '18 at 09:22
  • So if you use sudo apt-get --with-new-pkgs upgrade without running apt-mark auto <pkg>, will everything be fine? Is the second command only necessary if you do choose to manually install held-back packages? – crenshaw-dev Jun 19 '18 at 12:40
  • 2
    Yes. apt-mark auto <pkg> should only be necessary to mark a package as being automatically installed (here the man page). – Pablo Bianchi Jul 20 '18 at 04:37
  • 111
    For some reason sudo apt-get --with-new-pkgs upgrade still shows the packages as "kept back". No error message. – Franklin Yu Nov 12 '18 at 19:06
  • 3
    Just want to add that for many up to date debian 9.6 server instances this was the absolute safest solution without breaking things. Thank you for this, Pablo, as I had luckily tested other options on staging environments beforehand, and could admin many servers up to security standards thanks to the --with-new-pkgs inclusion with much cleaner results for general future package management. Really, this UNIX SE answer should be upvoted! – Julius Jan 09 '19 at 08:18
  • 2
    @MichaelCrenshaw yes, that's the point here. apt-mark auto <pkg>' is for when youapt-get install ` for a pkg that was previously marked auto. – drevicko May 24 '19 at 03:00
  • You can also add the --simulate switch to see what this command would do, without it actually doing it. – Andrew Jun 11 '19 at 05:29
  • 14
    This solution doesn't have the side effect of causing packages to be marked as "manually installed". It also doesn't have the side effect of "actually installing the dang packages". – Andrew Koster Oct 11 '21 at 20:38
  • 14
    This had no effect for me - packages still kept back. – UpTheCreek Mar 15 '22 at 12:33
  • 11
    This doesn't do anything. Still says The following packages have been kept back: – endolith Jul 30 '22 at 16:20
  • I think this one doesn't work if a package would have to be removed. – Esme Povirk Jul 30 '22 at 18:46
  • 1
    @endolith and everyone which this didn't work: Please check my related answer and tell us if it helps – Pablo Bianchi Jul 30 '22 at 18:56
  • 1
    @PabloBianchi I used sudo aptitude safe-upgrade as in the other answers – endolith Jul 31 '22 at 21:14
  • in my case the --with-new doesnt change anything, I get the same have been kept back message.

    But the Hint about make-auto below the main answer part is helpful. I already knew excplicit install can help, but also that it will do the manual-installed switch, which is not correct for some kind of dependency library I never installed manually, and this can lead to further problems. So thanks for that hint!

    – Henning Sep 02 '22 at 12:17
  • 1
    Warning! Marking packages as "auto" can cause problems if one of the kept-back packages was originally "manual", e.g. "kubuntu-desktop" is normally marked as "manual". If you mark it as auto using this procedure, the next time you do an upgrade it will show many important packages as ready for autoremoval because "they were automatically installed and are no longer required". It may be wise to first check the manual/auto status of the packages and preserve it after the update. – user272901 Dec 15 '22 at 20:12
  • I found that this answer only works as expected when I pass the package name: sudo apt-get --with-new-pkgs upgrade <packagename> – Flimm Apr 10 '23 at 10:35
  • This answer is not correct. Compare the manual for apt with the manual for apt-get. In apt, upgrade says "New packages will be installed if required to satisfy dependencies". In apt-get upgrade, "under no circumstances are [...] packages not already installed retrieved and installed". The apt manual does not document the option --with-new-pkgs, because it has no effect on apt. – sourcejedi Jun 19 '23 at 12:04
  • Using apt-get --wit-new-pkgs upgrade ...., one SHOULD name the packages that are kept back. When not doing so, nothing happens. – Luuk Jan 19 '24 at 16:56
200

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.

crenshaw-dev
  • 31,762
  • 43
    apt-get dist-upgrade is only dangerous if you have bad repositories in /etc/apt/sources.list*. It's good to be aware that dist-upgrade upgrades all packages, but with the default repositories, that should be fine. Not using dist-upgrade could be dangerous, as you might miss security updates. – Flimm Dec 27 '12 at 19:35
  • 12
    apt-get dist-upgrade can remove as well as add packages, but it is not really dangerous. Any package installation command can cause serious damage if you have problems in your sources.list file! A regular apt-get upgrade command will install any package from any software source that is enabled; dist-upgrade is not unique in this way. Furthermore, using aptitude to perform any operation at all, at least on amd64, is much more dangerous than running apt-get dist-upgrade, in a release where bug 831768 isn't fixed. – Eliah Kagan Mar 22 '13 at 14:03
  • For me, it was easier (local machine with X running) to just open synaptic and force the package's upgrade. For some reason it didn't seem to show up at all where you described in synaptic. – djvs Jul 27 '15 at 14:39
  • 17
    Also sudo aptitude safe-upgrade – msanford May 19 '16 at 15:31
  • 3
    @msanford Thank you! Your solution fixed it for me where sudo apt-get --with-new-pkgs upgrade did not. – John Mar 26 '20 at 09:36
  • 1
    dist-upgrade will not update/upgrade the whole distribution (like do-release-upgrade). It is a misnomer. Use full-upgrade equivalent. – Pablo Bianchi Mar 23 '22 at 21:42
  • 1
    @msanford Thank you! Your solution also fixed it for me where sudo apt-get --with-new-pkgs upgrade did not. – endolith Jul 30 '22 at 16:24
  • @msanford To go along with that, there's also sudo aptitude full-upgrade for when you don't mind it removing packages to upgrade ones that need it. – Brōtsyorfuzthrāx Sep 27 '22 at 01:28
127

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 3 categories of reasons for packages being kept back during apt upgrade.

1) 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>

2) 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 --with-new-pkgs:

    sudo apt upgrade --with-new-pkgs <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 --only-upgrade.

    sudo apt install --only-upgrade <package>
    

3) Phased updates

PhasedUpdates

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. This process allows us to automatically monitor for regressions and halt the update process if any are found.

You can check for phased updates with:

sudo apt -o APT::Get::Always-Include-Phased-Updates=true upgrade --dry-run

Lots more info here: What are phased updates, and why does Ubuntu use them?

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 <support@docker.com>
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 <support@docker.com> 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])

joelostblom
  • 1,337
  • 1
  • 10
  • 13
bernie
  • 2,151
  • 14
    If I understand correctly, there is a third reason for kept-back updates: Phased updates. These are gradually distributed to increasing portions of the user base until the update is made available to everyone. (see here) – Dunkelkoon Aug 10 '22 at 11:56
  • 1
    @Dunkelkoon Correct. When I did the comparison with apt show that the answer recommended for one of the packages that are being held back (gnome-tweaks), I found that the only differences between the outputs produced for the version I have installed, and that for the available update, were (1) the Version line, (2) the APT-Sources line, (3) that the installed version had the line APT-Manual-Installed: yes, and (4) that the available update had the line Phased-Update-Percentage: 30. – Teemu Leisti Sep 23 '22 at 06:48
  • 3
    I updated my answer to include PhasedUpdates. Thanks! – bernie Sep 29 '22 at 20:37
  • 6
    This should be the accepted answer – P Varga Dec 13 '22 at 21:41
  • This was very helpful, thank you. – Brian Smith Jan 18 '23 at 21:25
  • 6
    You can check for phased updates with sudo apt -o APT::Get::Always-Include-Phased-Updates=true upgrade --dry-run. – Ed McMan Jan 31 '23 at 14:06
  • Could the mismatch between an installed config file that has been changed on the system versus the one that a new version of an upgradable package wants to install, be another reason for that package upgrade to be held back? I'm thinking of the situation described here and that apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade can resolve. – cueedee Feb 02 '23 at 10:31
  • @cueedee That's an interesting scenario. I read the article and couldn't find something the results in a package being held back (unless you just don't answer the prompt). It seems like all the --force-* options simply allow to skip the prompt you'd get on upgrade, but none of them result in a package being held back. Did I miss something? – bernie Feb 02 '23 at 21:32
  • in my case, I just run the command sudo apt -o APT::Get::Always-Include-Phased-Updates=true upgrade (after seeing the effect with the --dry-run option) and it simply upgraded the kept back packages. everything is fine in my case. – logoff Feb 05 '23 at 10:00
  • 1
    @bernie - The situation was an unattended-upgrades setup that wouldn't progress completely, and a base-files package that was reported to be among those being "kept back". A manual apt-get upgrade --with-new-pkgs entered me into the dialog about two conflicting config files from base-files that had been customized locally (etc/issue{,.net}). After that, everything checked out OK again and so I figured that this must have been the reason for keeping back base-files. – cueedee Feb 06 '23 at 07:33
  • Ah I see. If I understand correctly, in that case, since this was an "unattended" procedure, apt-get couldn't show a prompt to ask you what it should do, so it refused to upgrade the package. – bernie Feb 06 '23 at 10:04
  • @bernie - Yes! Yes Indeed. But would base-files still have been listed in the report of "packages having been kept back", if the config-file conflict had not occured, or was the need to show the interactive dialog the only reason for doing so? – cueedee Feb 06 '23 at 14:38
  • That's a good question, but I don't know the answer :) Something to keep in mind though. I'm happy for you to edit this answer with additional information if you like. – bernie Feb 06 '23 at 15:39
  • There's a fourth, albeit this may not trigger unless you run unstable… when package A depends on a specific version of package B, and B had an update but A didn't (yet, or it had but it's stuck in the queue). B is held back, and "forcing" it will then remove A because its dependency will become unsatisfied. – Jürgen A. Erhard Apr 18 '23 at 12:59
  • @JürgenA.Erhard Perhaps I misunderstood, but I have the impression that this is included in 2) apt detects a dependency change. If you have a suggestion of an extra example to add to that section to illustrate your scenario I'm happy to accept it. – bernie Apr 30 '23 at 08:38
  • apt-mark showhold returns nothing but sudo apt install --no-install-recommends --no-install-suggests onedrive complaints about The following packages have unmet dependencies: onedrive : Depends: libc6 (>= 2.34) but 2.31-0ubuntu9.12 is to be installed Depends: libphobos2-ldc-shared98 (>= 1:1.28.0) but it is not installable E: Unable to correct problems, you have held broken packages. – Kvothe Oct 24 '23 at 16:36
88

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.

les_h
  • 304
Afilu
  • 1,005
  • 2
    This just gives sudo: aptitude: command not found – MikeB Aug 14 '22 at 14:27
  • 6
    @MikeB Did you first install aptitude, as the answer instructed? – Teemu Leisti Sep 23 '22 at 06:28
  • 4
    this is the correct answer – acgbox Jan 26 '23 at 16:31
  • 1
    This worked for me (+1), but I'd like to understand what's happening better. sudo apt-get dist-upgrade did not upgrade the packages for me, so it's not just that it's a safer version of dist-upgrade. – Charles Jan 26 '23 at 20:18
  • sudo apt-get --with-new-pkgs upgrade had also failed for me. – Charles Jan 26 '23 at 20:19
  • @Charles If you had the same issue as me, you have to provide the list of kept-back packages after the command (so sudo apt-get --with-new-pkgs upgrade packageName [packageName...]. For some reason most of the answers here leave that information out. – TommyPeanuts Feb 18 '23 at 08:38
  • This worked for me after sudo apt-get --with-new-pkgs upgrade failed. Thank you! – Gabriel Mar 02 '23 at 20:44
  • This is what worked for me. I was following comments in the main question and pointed out to this answer. I guess it would be good to explain why are these two commands solving the issue,thanks! – Dazag Apr 12 '23 at 11:30
64

This has been happening more since I upgraded to Ubuntu 22.04 jammy.

The reason is usually phased updates. (Thanks to @louis-waweru for the link.)

  1. The solution is to ignore those "have been kept back" messages. When the repository maintainers deem these packages safe enough for you to install, you will get them.

  2. If you absolutely must get these updates, you can create the file /etc/apt/apt.conf.d/99-Phased-Updates with the contents:

Update-Manager::Always-Include-Phased-Updates "1";
APT::Get::Always-Include-Phased-Updates "1";
bentolor
  • 613
Joe
  • 1,029
  • 1
  • 8
  • 8
  • 12
    This! This seems to be the answer relevant to me. Further note: when I do apt list --upgradable, it shows various packages and old and new versions. I can then do apt show package -a on any of the listed packages, and, at least in my case, I'll see something like Phased-Update-Percentage: 70 or Phased-Update-Percentage: 0 or whatever. See also: https://wiki.ubuntu.com/PhasedUpdates – lindes Sep 17 '22 at 17:09
  • You can also avoid using apt and use aptitude instead. If you run sudo aptitude upgrade or sudo aptitude dist-upgrade, it will install all the available upgrades without minding about phased updates. – Mikko Rantalainen Jan 24 '24 at 17:23
43

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.

Pablo Bianchi
  • 15,657
jbowtie
  • 13,195
  • 7
    Is there a way to determine whether the held package needs a dependency that can't be installed or if it is being held because other packages depend on it. I have many held packages and I believe both of these cases may apply on my system. – Jake Dec 08 '16 at 09:29
  • 1
    Thanks, the second reason was the issue for me. Even apt-get dist-upgrade refused to install it. Inspecting the package with aptitude showed that it depends on a package that isn't available. I guess I'll have to wait. – jlh May 02 '18 at 14:55
30

Ubuntu 18.04 LTS Bionic and newer Ubuntu versions … provide a streamlined syntax via apt full-upgrade which functions like 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: sudo apt full-upgrade remains on the current distribution.

See: apt man page: 18.04, 20.04, 22.04, 22.10

marc-medley
  • 1,140
  • After this operation, 2,548 MB disk space will be freed. You are about to do something potentially harmful. To continue type in the phrase 'Yes, do as I say!' – Arun Panneerselvam Apr 01 '20 at 22:59
  • 3
    full-upgrade does the same thing as dist-upgrade! This answer is wrong! See here https://askubuntu.com/questions/770135/apt-full-upgrade-versus-apt-get-dist-upgrade – bernie Feb 14 '21 at 14:17
  • @bernie Answer updated per your observation. – marc-medley Feb 16 '21 at 04:51
26

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.

txwikinger
  • 28,462
  • What do you base that likelihood on, without knowing whatever he ran an apt-get upgrade or an apt-get dist-upgrade (alt. the aptitude equivalents)? – andol Jul 31 '10 at 22:21
  • 2
    this is the most occurring problem in support questions and bugs – txwikinger Jul 31 '10 at 22:25
  • Agreed. You should probably wait and check you apt_preferences. This is often caused by development archives where the and available packages dependencies are changing very quickly. Wait for them to settle down and you may not need to dist-upgrade at all. If you'd still like to dist-upgrade, then look at the NEW packages to be installed and the packages to be removed before going ahead. – Umang Aug 01 '10 at 02:29
  • 1
    This is my case because I get the "kept back" message using dist-upgrade – Postadelmaga Aug 17 '12 at 09:02
  • 1
    In cases where this problem is due to a messup with apt preferences (pinning), I found reinstallation of the kept packages helped me: apt-get install --reinstall <packages>. – tanius Apr 13 '14 at 11:11
20

This worked for me

sudo aptitude full-upgrade
Eric Carvalho
  • 54,385
Singh
  • 217
  • 2
    Even aptitude upgrade worked for me. – Bibhas Dec 14 '13 at 16:15
  • I`am using Ubuntu 14.04 and I does not have aptitude command line – ahmed hamdy Mar 31 '15 at 13:33
  • apt-get dist-upgrade gave me the same message, but this solved it for me. I had a package which was breaking the upgrade of another package. I didn't need the one I installed, so aptitude full-upgrade gave me the option to remove it so it could upgrade everything else. – f.ardelian Apr 30 '15 at 00:53
14

This is usually because the package has added a dependency, and upgrade doesn't want to add it for you without permission.

If you run:

sudo apt-get install gimp gimp-data libgegl-0.0-0 libgimp2.0

Then the new versions should be installed together with their new dependency.

  • Upgrades specific packages (and their dependencies) without the commitment (risks) of a dist-upgrade. – John Mee Sep 21 '15 at 07:43
  • 1
    The package manager doesn't want to manage packages "without my permission" even though I manually typed sudo apt upgrade. Lol. – Andrew Koster Oct 11 '21 at 20:40
9

I have found that aptitude does a better job at upgrading packages if the versions differ just slightly. I had a situation like this:

me@compy:/etc/apt$ apt-cache policy gzip
gzip:
  Installed: 1.3.5-15
  Candidate: 1.3.5-15+etch1
  Version table:
     1.3.5-15+etch1 0
        500 http://archive.debian.org etch/main Packages
 *** 1.3.5-15 0
        100 /var/lib/dpkg/status

This made apt-get hold back the update, but aptitude updated it just fine. I'm unsure which algorithm is used to determine if a package should be updated or not. I guess these two had the same version, only a different 'qualifier'. But in any case, apt-get wouldn't update it, but aptitude would.

8

Update/Upgrade not working [last answer]

The kept-back packages (...) are currently in Phased Updates.

Phased Updates is one precaution to prevent everybody from receiving a buggy package via upgrade: Some people get the upgraded a few days earlier, others a few days later. This provides an opportunity to pause distribution if early folks report problems.

There is nothing wrong. Your system is NOT broken.

  • 2
    I don't know yet if this is the *correct answer, but I do know that the highly-upvoted answers* here are *incorrect answers* - unless perhaps you're running a 10-year-old-system. – Seamus Sep 15 '22 at 23:04
  • For what it's worth, this seems to be what I'm running up against. More info at https://wiki.ubuntu.com/PhasedUpdates ... I wish apt would mention this in the "kept back" messaging! – lindes Sep 17 '22 at 17:11
  • 1
    @Seamus the question is from 2010, so no wonders they answers are mostly not correct if the behaviour changed in the OS version released in 2022. Seems there's a new mechanism which this answer is valid for and seems like the mechanism is quite good to avoid unnecessary harm. As lndes noted, it would be good if apt mentioned something about this new mechanism. – tymik Jan 30 '23 at 15:28
7

This looks like the correct way to reinstall kept back package:

apt-get install --reinstall libjpeg-progs

At least this worked for me when libjpeg-progs was stuck after upgrading from Ubuntu 14.04 to 16.04. I'm sure you can do the same with any other kept back app, e.g. gimp.

Source

Pablo Bianchi
  • 15,657
5

While other answers have cautioned that apt dist-upgrade might remove programs, notice that you can just run the command and then answer "no" to the "Do you want to continue?" question in order to investigate what apt would do.


After updating a raspberry pi from buster to bullseye I ended up with apt reporting

The following packages have been kept back:
  sshfs

So I started searching for the error message, landed on this page, read a few answers and then ran

$ apt-get dist-upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages will be REMOVED:
  fuse
The following NEW packages will be installed:
  fuse3 libfuse3-3
The following packages will be upgraded:
  sshfs
1 upgraded, 2 newly installed, 1 to remove and 0 not upgraded.
Need to get 147 kB of archives.
After this operation, 196 kB of additional disk space will be used.
Do you want to continue? [Y/n] 

At this point it is clear that fuse had been replaced by fuse3 and I am happy to let apt remove it.


Your situation might be different but doing a (potential) dry-run will give you more detailed information and quite possibly answer the "why" question.

hlovdal
  • 171
5

In my case packages held back were those related to linux-headers and kernel. I came to this by trying to solve an issue with having a red exclamation mark in the notification area and not being able to update packages.

To solve it, I did not have to use neither dist-upgrade nor manual apt-get install xxx.

What I did and has helped has been simple and clean:

sudo apt-get update
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get upgrade

I had to manually confirm Grub update and its configuration.

Then I just worked with the computer for a while and then standard update dialogue has appeared again finally including "Ubuntu base" section with kernel and related. The update was performed without any trouble and I do not see any held back packages any more.

Also, it is very important to keep in mind that those *buntu updates including kernel updates are sensitive to hibernation - I've got this problem several times and I always get it resolved by restarting the machine and performing the steps above.

So maybe this would be just enough?!

(situation being described in here is related to my Xubuntu 15.10 in the end of december 2015)

crysman
  • 508
  • 8
  • 17
5

I ran into this problem when a new kernel was released. (Possibly because I have unstable updates enabled.) I found the simplest way to do the install was through Ubuntu's graphical installer (update-manager).

Kazark
  • 698
4

In actual fact, the switch you need is dselect-upgrade which installs / removes dependencies for the particular package set involved.

JoKeR
  • 6,972
  • 9
  • 43
  • 65
Johnny
  • 49
3

For me and several commenters on Pablo's answer,

sudo apt-get --with-new-pkgs upgrade  # No effect

had no effect. I do not care to have my package marked as manually installed, so I did the following, using kept back package docker-ce as an example:

sudo apt install docker-ce  # Answer no, do not install

Abort the installation by answering n. Observe the new package(s) that would have been installed, and install them:

sudo apt install docker-ce-rootless-extras

Now apt upgrade will upgrade the previously kept back package:

sudo apt upgrade  # Upgrades docker-ce
3

I ran into this problem using synaptic because it appeared to hang, and to try and fix this I re-booted and tried again.

SOLUTION: Then I discovered an informative message as part of the package with some post-installation instructions for me.

I had to hit "details", and then 'q' for quit after reading the message, and then things proceeded normally.

3

I have read all the posts and found that there are many interesting explanations. I was trying all of them but have not any results completely. I have a problem with mysql-utilities which I couldn't upgrade. The updating was proposed by the system. So, I want to show some steps to do it. Of course, I will repeat in some moments all of the aforementioned posts. Here is my mistake, yes I found it by already existed posts, but what should I do next? enter image description here

The next step is:

sudo apt-get --purge remove mysql-utilities

The results we can see in the image beneath. I remove the package and check this by command:

sudo apt-get -f install

Results - Fine! Later I installed this new version of package correctly. enter image description here

This way, I think can help for more new people because having other packages we can do the same steps.

Once, I am sorry, when I repeated in some places other posts.

  • 9
    Please don't use screenshots for terminal text, since that makes it unsearchable by Google and unreadable by some people. Instead, paste the terminal text into your answer, select that text, and press the {} button in the editor to properly format it. – Chai T. Rex Jan 25 '18 at 22:14
  • @ChaiT.Rex Thanks for remarks, I will take it in opinion for the future. – Vasyl Lyashkevych Jan 25 '18 at 22:43
2

This one line solves the issue automatically for me:

sudo apt-get install --only-upgrade `sudo apt-get upgrade | awk 'BEGIN{flag=0} /The following packages have been kept back:/ { flag=1} /^ /{if (flag) print}'`

It runs minimal update with --only-upgrade flag so it should not add any unnecessary packages to the dependency.

How: the line above looks for the "The following packages have been kept back" message in apt update and if found' it feeds the list to apt-get install --only-upgrade

Note: be very careful with any modifications to your system. Doing things with apt may leave your system broken!

I always run apt update a&& apt upgrade just to make sure the upgrade is stable.

QT-1
  • 1,402
1

I always run dist-upgrade on my dev laptop because I like latest and greatest, it is not do-release-upgrade which actually upgrades to a newer version,

On ubuntu 22.04 I had this issue with both :

ubuntu@ubuntu-inspiron-5482:~$ sudo apt dist-upgrade 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  python3-distupgrade ubuntu-release-upgrader-core ubuntu-release-upgrader-gtk
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

and

ubuntu@ubuntu-inspiron-5482:~$ sudo apt-get --with-new-pkgs upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  python3-distupgrade ubuntu-release-upgrader-core ubuntu-release-upgrader-gtk
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

So both solutions from the highest rated answer do not work. What worked is to install a package, it actually had the other two as dependencies:

sudo apt install ubuntu-release-upgrader-core 

After that the 3 packages installed and everything is up to date. I wonder why those were kept back, I seen no difference on my system, but perhaps there is an issue with the new release running the tools.

Anyway, this is the only option that works for me.

Vincent Gerris
  • 2,437
  • 1
  • 20
  • 14
  • 1
    See this: https://askubuntu.com/questions/1420969/how-to-force-packages-that-have-been-kept-back-to-be-installed-as-automat – FedKad Aug 09 '22 at 08:46
  • Regarding what FedKad said (22.04 LTS on WSL2): https://i.stack.imgur.com/GiSFp.png – Louis Waweru Aug 09 '22 at 08:58
1

Some recently installed packages may require a reboot before new can be installed (and the latter are held back), e.g.:

$ sudo apt list --upgradable
Listing... Done
distro-info-data/jammy-updates,jammy-updates 0.52ubuntu0.2 all [upgradable from: 0.52ubuntu0.1]
gnome-shell-common/jammy-updates,jammy-updates 42.5-0ubuntu1 all [upgradable from: 42.4-0ubuntu0.22.04.1]
gnome-shell/jammy-updates 42.5-0ubuntu1 amd64 [upgradable from: 42.4-0ubuntu0.22.04.1]
grub-efi-amd64-bin/jammy-updates 2.06-2ubuntu10 amd64 [upgradable from: 2.06-2ubuntu7]
grub-efi-amd64-signed/jammy-updates 1.182~22.04.1+2.06-2ubuntu10 amd64 [upgradable from: 1.180+2.06-2ubuntu7]
mirekphd
  • 133
0
The following packages have been kept back:
  clang-9 cpp g++ gcc gcc-10-base kali-linux-default lib32gcc-s1 lib32stdc++6 libatomic1 libcc1-0
  libclang-common-9-dev libclang-cpp9 libgcc-s1 libgfortran5 libgomp1 libitm1 libllvm9 liblsan0 libobjc4
  libpython2-stdlib libquadmath0 libstdc++6 libtsan0 libubsan1 linux-headers-amd64 llvm-9 llvm-9-dev llvm-9-runtime
  llvm-9-tools python2 python2-minimal python3-chardet python3-pandas python3-pandas-lib

apt upgrade; apt update just kept coming back to that and wouldn't install anything. There was a huge block of stuff as well that needed to be autoremoved and that went fine, but still would not install the kept back packages. I tried the easy options 1 and 2 way up there at the beginning of this thread and they did not work.

So I just did apt install /that whole list of kept back packages/, and it all started going.

I've actually never run into this problem before. I just thought it was odd that apt update; apt upgrade didn't work but apt install and then copying that whole list in went off without a hitch and it's working fine now.

And I'm going to apologize now. I wasn't using an ubuntu distribution (I just realized this). I was actually updating a Kali installation when this all occurred. I've never seen anything like this on Ubuntu.

Let me know if I should delete this post (still new).

Ron

0

Following a do-release-upgrade, your third-party or private repositories (such as PPAs) may be disabled. This can stop a package being updated because it can no longer find the dependencies it needs, and/or old packages conflict with newer packages.

Have a look through your .list files, usually in /etc/apt/sources.list.d, to see what needs to be re-enabled.

Then run apt update and try again.

This is happened to me after a do-release-upgrade on a Google VM.

Ken Sharp
  • 991
  • 8
  • 31
0

In my case, I got the message because I run sudo apt upgrade without first running sudo apt update.

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  alsa-ucm-conf fonts-opensymbol libreoffice-base-core libreoffice-calc libreoffice-common libreoffice-core libreoffice-draw
  libreoffice-gnome libreoffice-gtk3 libreoffice-help-common libreoffice-help-en-gb libreoffice-help-en-us libreoffice-impress
  libreoffice-l10n-en-gb libreoffice-l10n-en-za libreoffice-math libreoffice-style-colibre libreoffice-style-elementary
  libreoffice-style-yaru libreoffice-uiconfig-calc libreoffice-uiconfig-common libreoffice-uiconfig-draw
  libreoffice-uiconfig-impress libreoffice-uiconfig-math libreoffice-uiconfig-writer libreoffice-writer libuno-cppu3
  libuno-cppuhelpergcc3-3 libuno-purpenvhelpergcc3-3 libuno-sal3 libuno-salhelpergcc3-3 python3-uno uno-libs-private ure
0 upgraded, 0 newly installed, 0 to remove and 34 not upgraded.

Running sudo apt-get --with-new-pkgs upgrade alsa-ucm-conf fonts-opensymbol libreoffice-base-core libreoffice-calc libreoffice-common libreoffice-core libreoffice-drawlibreoffice-gnome libreoffice-gtk3 libreoffice-help-common libreoffice-help-en-gb libreoffice-help-en-us libreoffice-impresslibreoffice-l10n-en-gb libreoffice-l10n-en-za libreoffice-math libreoffice-style-colibre libreoffice-style-elementarylibreoffice-style-yaru libreoffice-uiconfig-calc libreoffice-uiconfig-common libreoffice-uiconfig-drawlibreoffice-uiconfig-impress libreoffice-uiconfig-math libreoffice-uiconfig-writer libreoffice-writer libuno-cppu3libuno-cppuhelpergcc3-3 libuno-purpenvhelpergcc3-3 libuno-sal3 libuno-salhelpergcc3-3 python3-uno uno-libs-private ure as suggested in other answers did not help.

$ sudo apt-get --with-new-pkgs upgrade alsa-ucm-conf fonts-opensymbol libreoffice-base-core libreoffice-calc libreoffice-common libreoffice-core libreoffice-drawlibreoffice-gnome libreoffice-gtk3 libreoffice-help-common libreoffice-help-en-gb libreoffice-help-en-us libreoffice-impresslibreoffice-l10n-en-gb libreoffice-l10n-en-za libreoffice-math libreoffice-style-colibre libreoffice-style-elementarylibreoffice-style-yaru libreoffice-uiconfig-calc libreoffice-uiconfig-common libreoffice-uiconfig-drawlibreoffice-uiconfig-impress libreoffice-uiconfig-math libreoffice-uiconfig-writer libreoffice-writer libuno-cppu3libuno-cppuhelpergcc3-3 libuno-purpenvhelpergcc3-3 libuno-sal3 libuno-salhelpergcc3-3 python3-uno uno-libs-private ure
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package libreoffice-drawlibreoffice-gnome
E: Unable to locate package libreoffice-impresslibreoffice-l10n-en-gb
E: Unable to locate package libreoffice-style-elementarylibreoffice-style-yaru
E: Unable to locate package libreoffice-uiconfig-drawlibreoffice-uiconfig-impress
E: Unable to locate package libuno-cppu3libuno-cppuhelpergcc3-3

I ran sudo apt update before sudo apt upgrade and it worked out.

$ sudo apt update
Hit:1 https://dl.winehq.org/wine-builds/ubuntu mantic InRelease
Hit:2 http://it.archive.ubuntu.com/ubuntu mantic InRelease                                                                      
Get:3 http://it.archive.ubuntu.com/ubuntu mantic-updates InRelease [109 kB]                                                     
Hit:4 http://security.ubuntu.com/ubuntu mantic-security InRelease
Hit:5 http://it.archive.ubuntu.com/ubuntu mantic-backports InRelease
Get:6 http://it.archive.ubuntu.com/ubuntu mantic-updates/main amd64 Packages [331 kB]
Get:7 http://it.archive.ubuntu.com/ubuntu mantic-updates/main i386 Packages [168 kB]
Get:8 http://it.archive.ubuntu.com/ubuntu mantic-updates/universe amd64 Packages [296 kB]
Get:9 http://it.archive.ubuntu.com/ubuntu mantic-updates/universe i386 Packages [123 kB]
Fetched 1,027 kB in 1s (792 kB/s)                       
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
34 packages can be upgraded. Run 'apt list --upgradable' to see them.
apaderno
  • 289
-1

For the very specific flavour of this problem where the proprietary nvidia drivers are halfway updated to a new version, I reinstalled them using the driver manager. To give some context: I was stuck halfway between the 440 and 450 version of the driver and a whole package of libnvidia 440 packages were kept back. This resulted in my kubuntu being stuck at the spash screen after grub. To get into the system, I had to add "nomodeset" to the grub command as described here.

In this specific case

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

did have no effect. However, I was able to reinstall the drivers through the additional driver management. In my case, on Kubuntu I started

sudo kubuntu-driver-manager

On Ubuntu you can reach the same thing via System Settings > System > Software & Updates > Additional Drivers

There I selected the 450 driver and the graphic drivers were reinstalled, resulting in a properly booting machine.

m00am
  • 606
  • 8
  • 27