67

Executing sudo apt update ended with

Reading package lists... Done
Building dependency tree       
Reading state information... Done
2 packages can be upgraded. Run 'apt list --upgradable' to see them.

Executing apt list --upgradable gave me

Listing... Done
onionshare/bionic,bionic 2.2.ppa1-1 all [upgradable from: 2.1-1]
ring-all/unknown 20190927.2.c2af011~dfsg1-1 amd64 [upgradable from: 20190629.2.c07ef23~dfsg1-1]

But executing sudo apt upgrade does not upgrade the upgradable packages:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
  1. Why is that? Unmet dependencies possibly?
  2. Can I (manually) upgrade the listed packages, and if so: how?

Update: See this pastebin for a full transcript.

marianoju
  • 1,515
  • 2
    Is there anything like kept back in the output? – Kulfy Oct 18 '19 at 11:32
  • No, that's pretty much all of it. I have added to the post a link to a pastebin with a full transcript. – marianoju Oct 18 '19 at 18:08
  • 4
    What happens if you run sudo apt full-upgrade instead? – pomsky Oct 19 '19 at 05:27
  • @pomsky Same as with sudo apt upgrade – marianoju Oct 20 '19 at 11:01
  • I suspect the problem here was they were using a random nightly ppa (https://dl.jami.net/ring-nightly/ubuntu_19.04 ring InRelease). If you can't troubleshoot a failed apt install that's a very risky route to take. I would ppapurge that and find a stable ppa to add (from jami.net if you trust that source). – pbhj Sep 14 '22 at 15:05
  • @pbhj I can not verify this explanation as time has passed and I have moved on, but thanks for offering your opinion with regards to the ring-all package. Upgrading onionshare failed due to python3-flask-httpauth dependency being not installable (this has been discussed on GitHub, see issue #1052). – marianoju Sep 16 '22 at 08:14
  • 1
    @pbhj I notice that your interesting flag on this question was declined (not by me). I am sympathetic to your flag as the answers don't seem to offer anything of special value (especially the highest voted, which I notice I downvoted on a previous visit to this page). I did check the anonymous feedback though and it is quite positive, so I feel it would be bad to delete the whole page. Moreover, and most importantly, your comment suggests that you have a useful insight that might be developed into an answer? :) – Zanna Sep 16 '22 at 10:29
  • 1
    marianoju it might be good to flesh out your answer (which has a lot of positive anonymous feedback btw, so it must be good and helpful as it is) to actually talk about that, perhaps with some summary and quotes from the GitHub issue which isn't all that easy to follow. Not sure if you could make the question and especially its title more specific as well? – Zanna Sep 16 '22 at 10:31

5 Answers5

35

In this case “upgradable packages” are actually not upgradable because they have unmet dependencies.

To reproduce: try to update the specific packages in question (see How To Update A Specific Package In Ubuntu) by executing sudo apt-get install --only-upgrade <packagename>. If any package has unmet dependencies, the upgrade will fail due to

E: Unable to correct problems, you have held broken packages.

Upgrading these packages would require to resolve the unmet dependencies. Information on that can be found in the answer to “How do I resolve unmet dependencies after adding a PPA?” and “Fixing Unable to correct problems, you have held broken packages”.

marianoju
  • 1,515
  • 1
    The underlying issue of the not installable dependency python3-flask-httpauth has been discussed on GitHub (see #1052). – marianoju Jul 31 '20 at 20:43
  • 4
    There might be cases where this is true, but not for me. I've ran both sudo apt full-upgrade and sudo apt-get dist-upgrade and both reported 5 packages being kept back, but I when I ran sudo apt install and gave the names of the packages, they were all updated without any issue. – iGEL Feb 05 '23 at 10:07
  • 1
    I had the same problem, so I ran sudo apt install --only-upgrade <packagename> for every package manually and didn't get an error. I don't get why I can upgrade packages manually but not using sudo apt upgrade... – Célestin Taramarcaz Apr 15 '23 at 12:35
  • sudo apt-get install --only-upgrade <packagename> on the first upgradable package (r-base) gave apt upgrade some leeway to fix the rest recursively along with autoremove. Thanks – Johan Nov 05 '23 at 09:11
25

You can run the command line below for upgrade all upgradable packages and their dependencies:

sudo apt-get dist-upgrade
pomsky
  • 68,507
giapvn
  • 285
  • 3
  • 3
  • 9
    The command sudo apt-get dist-upgrade does not upgrade all upgradable packages and their dependencies. Output for me is:
    Building dependency tree       
    Reading state information... Done
    Calculating upgrade... Done
    The following packages have been kept back:
      ring-all
    0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.``` (Same as `sudo apt upgrade` and `sudo apt full-upgrade`)
    
    – marianoju Apr 10 '20 at 09:59
14

The missing package NAMES in YOUR case won't necessarily be the same as in this example. But this shows how to fix the problem. The technique works regardless of what names you see in your output. So substitute the actual file names like ubuntu-advantage-tools or libnfsidmap1 with whatever YOUR computer says needs to be upgraded.

All of these commands need to be run as root. We do this by using sudo to change the user in the terminal without having to actually be logged into a session as root. To do this, type:

sudo su

...and enter your root password when prompted. The su part would switch users. When entered without anything else after it, the default to switch to is root. Now you have permission to dramatically screw up the computer so be 'root' carefully!

Otherwise you have to type sudo in front of all of these commands individually. Some linux purists think its wrong to sudo su, but I assure you, it is precisely the same as typing sudo over and over again for each command.

Run:

apt update

and then

apt upgrade

...you might get an output like:

1 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.

...which shows eight packages not upgraded.

Other update related commands might provide a message like:

The following packages have been kept back: evolution evolution-common evolution-plugin-bogofilter evolution-plugin-pstimport evolution-plugins libevolution libnfsidmap1 ubuntu-advantage-tools

You need to fix these listed packages that might be missing dependencies causing them to not be upgraded the easy way. Nobody has thought to include a subroutine in apt upgrade to handle these issues automatically. So we are stuck doing it ourselves.

To list the packages, you should then run:

apt list --upgradable

You should then manually install those listed packages.

apt install evolution evolution-common evolution-plugin-bogofilter evolution-plugin-pstimport evolution-plugins libevolution libnfsidmap1

Notice how you can just enter all the packages with a space in between their names instead of running apt install for each individually. You can copy this list directly in the terminal from the previous not upgraded output. You have to right click and select 'copy' or 'paste' when dealing with stuff in the terminal. Ctrl C and Ctrl V keyboard commands won't work on terminal outputs.

Of course doing all of this might still not fix all of them. You might get an output like:

6 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

or

2 packages can be upgraded. Run 'apt list --upgradable' to see them.

You can then run:

apt-get --with-new-pkgs upgrade

...to show the remaining packages. This should output something like

The following packages have been kept back: libnfsidmap1 ubuntu-advantage-tools

Then you just need to manually install them individually for some ungodly reason. In my case I entered:

apt install ubuntu-advantage-tools

and

apt install libnfsidmap1

Again, the names of what was installed here should be replaced with what YOUR computer says wasn't upgraded.

This should fix the problem with the remaining two that wouldn't install when in the list command earlier. Running apt update and then apt upgrade should then output:

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

DONE!

You might also want to run:

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

and then

sudo apt autoremove

as I have seen suggested elsewhere. But this alone didn't solve my problem.

user28788
  • 119
  • 1
    "Some ungodly reason" could very well be phased updates with the latest version of Ubuntu. – Artur Meinild Oct 06 '22 at 20:04
  • 1
    I suggest simply running each command with sudo rather than using sudo su. In any case, the password to be used is one's own, not root's – Zanna Oct 31 '22 at 15:02
3

After updating and upgrading with sudo apt update && sudo apt upgrade, this is the correct solution that always works:

sudo apt install <list of packages kept back>
karel
  • 114,770
  • 4
    This will probably work in most cases, but not when “upgradable packages” are actually not upgradable because they have unmet dependencies, see above. There is no “correct solution that always works”. – marianoju Sep 16 '22 at 07:56
2

I suggest running:

sudo apt-get upgrade

This worked for me. It will tell you how many packages it upgraded, how many new ones were installed, how many were deleted, and how many were not upgraded (kept back).

I had packages that were kept back, so after reading this post, which provides multiple solutions, I ran the following to install the packages that were kept back:

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

This will also include which packages are no longer needed and could be removed. Per the output's instructions, I ran the following to remove them:

sudo apt autoremove

Lastly I ran the first code again, just to make sure all was clear and would get the output "0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."

dahiana
  • 145