61

I am not sure what caused this error, but here is what the whole error says, and also this is sitting as a notification, and preventing me from updating any software using Update Manager - Please provide some assistance or tell me how to figure out what to do to fix it.

Could not calculate the upgrade

An unresolvable problem occurred while calculating the upgrade.

Please report this bug against the 'update-manager' package and include the following error message:
'E:Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.'
Eliah Kagan
  • 117,780
Jesse
  • 611
  • 1
  • 5
  • 3
  • Why don't you check the output of the below? apt-mark showhold If the dependencies are held, you will never be able to upgrade – Raghaha Dec 11 '20 at 12:44

6 Answers6

29

This post may solve your issue. To summarise,

  1. Open the /var/log/dist-upgrade/apt.log log file in a text editor.
  2. Locate any "broken" packages and remove them with sudo apt-get remove <package>.

Note: in newer versions, the log is located in /var/log/apt/term.log instead.

Pykler
  • 667
  • 2
    +1. Worked perfectly. In my case, I just tried to apt-get remove a single pkg, which indicated other pkgs that depend on it to be removed too. Those pkgs were the ones that are distro-specific and their upgrade path was unknown to Ubuntu. – IsaacS Dec 18 '12 at 22:46
  • 19
    cat: /var/log/dist-upgrade/apt.log: No such file or directory – Braden Best Oct 24 '14 at 03:39
  • I tried this. I found "this likely means your installation is broken" text, but do not know what package that refers to.... – Scorb Aug 12 '16 at 01:32
  • 1
    @ScottFlog in the /term.log and try to identify what it was trying to install. – Pykler Aug 12 '16 at 14:28
  • But what to do then? Run do-release-upgrade again? That tells me Please install all available updates for your release before upgrading. now. – Albert Dec 27 '21 at 09:25
  • In my case apt-get remove XXX did not work because it showed the same pkgProblemResolver error. However, dpkg --purge XXX worked for uninstalling some package, or maybe showed other packages I also needed to uninstall and then worked. – Albert Dec 27 '21 at 10:15
  • 1
    It did not work for me. I don't have seemingly broken package. My file was in /var/log/apt/term.log – desmond13 Nov 11 '22 at 16:48
  • Impossible, some of them are depended by essential system packages. Also this takes too long – tribbloid Jan 09 '23 at 08:39
  • i had such a case and found amongst a few other notes the window manager package "mutter" as the culprit making the upgrade process stop. as this created the problem in a log-able fashion i would have expected the do-tooling to also report it to the top where the end user does sit. – Alexander Stohr Jan 26 '24 at 14:41
13

Try:

sudo apt-get update && sudo apt-get upgrade

Then run the update-manager again.

jlb
  • 247
  • 1
  • 6
9

I got this error when doing upgrade from 16.04 to 18.04 and power-lost in the middle.

This is what the error looked like, and apt-get install -f does not fix it.

$ sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 gir1.2-gtk-3.0 : Depends: gir1.2-pango-1.0 (>= 1.40.5) but 1.38.1-1 is installed
                  Depends: libgtk-3-0 (>= 3.22.29) but 3.18.9-1ubuntu3.3 is installed
 hplip : Depends: hplip-data (= 3.17.10+repack0-5) but 3.16.3+repack0-1 is installed
         Depends: printer-driver-hpcups (= 3.17.10+repack0-5) but 3.16.3+repack0-1 is installed
         Depends: libsane1 (>= 1.0.24) but it is not installed
 libhpmud0 : Depends: libsnmp30 (>= 5.7.3+dfsg-1.8ubuntu3~dfsg) but 5.7.3+dfsg-1ubuntu4.2 is installed
 onboard : Depends: onboard-common (< 1.4.1-2ubuntu1.1) but it is not installed
           Depends: onboard-common (>= 1.4.1-2ubuntu1) but it is not installed
           Depends: libhunspell-1.6-0 but it is not installed
           Recommends: onboard-data (>= 1.4.1-2ubuntu1) but 1.2.0-0ubuntu5 is installed
 python3 : Depends: python3.6 (>= 3.6.7-1~) but it is not installed
           Depends: libpython3-stdlib (= 3.6.7-1~18.04) but 3.5.1-3 is installed
 python3-apt : Depends: libapt-inst2.0 (>= 1.6.5~) but 1.2.29ubuntu0.1 is installed
               Depends: libapt-pkg5.0 (>= 1.6.5~) but 1.2.29ubuntu0.1 is installed
 python3-cryptography : Depends: python3-asn1crypto (>= 0.21.0~) but it is not installed
                        Depends: python3-idna (>= 2.1) but 2.0-3 is installed
 python3-gdbm : Depends: libgdbm5 (>= 1.14) but it is not installed
 python3-pil : Depends: libwebp6 (>= 0.5.1) but it is not installed
               Depends: libwebpdemux2 (>= 0.5.1) but it is not installed
               Depends: libwebpmux3 (>= 0.6.1-2) but it is not installed
               Recommends: python3-olefile but it is not installed
 python3-systemd : Depends: libsystemd0 (>= 233) but 229-4ubuntu21.16 is installed
 python3-uno : Depends: libreoffice-core (= 1:6.0.7-0ubuntu0.18.04.2) but 1:5.1.6~rc2-0ubuntu1~xenial6 is installed
               Depends: python3.6 but it is not installed
               Depends: uno-libs3 (>= 5.3.0~alpha) but 5.1.6~rc2-0ubuntu1~xenial6 is installed
 python3.6-dev : Depends: python3.6 (= 3.6.7-1~18.04) but it is not installed
 totem-plugins : Depends: libgtk-3-0 (>= 3.19.4) but 3.18.9-1ubuntu3.3 is installed
                 Depends: liblirc-client0 but it is not installed
                 Depends: libtotem0 (>= 3.26.0-0ubuntu6.2) but 3.18.1-1ubuntu4 is installed
                 Depends: totem (= 3.26.0-0ubuntu6.2) but 3.18.1-1ubuntu4 is installed
                 Depends: gir1.2-totem-1.0 (= 3.26.0-0ubuntu6.2) but 3.18.1-1ubuntu4 is installed
 virtualbox : Depends: python3.6 but it is not installed
              Depends: libgsoap-2.8.60 but it is not installed
              Depends: libpng16-16 (>= 1.6.2-1) but it is not installed
              Recommends: libqt5core5a (>= 5.9.0~beta) but 5.5.1+dfsg-16ubuntu7.5 is installed
 virtualbox-qt : Depends: libqt5core5a (>= 5.9.0~beta) but 5.5.1+dfsg-16ubuntu7.5 is installed
                 Depends: libqt5widgets5 (>= 5.7.0) but 5.5.1+dfsg-16ubuntu7.5 is installed
                 Depends: libqt5x11extras5 (>= 5.6.0) but 5.5.1-3build1 is installed
E: Unmet dependencies. Try using -f.

I also tried sudo apt-get remove packages in /var/log/dist-upgrade/apt.log but that didn't work, too.

This one worked for me

dpkg -l | grep ^iU | awk '{print $2}' | xargs sudo dpkg --purge 

It removed broken packages then I ran

 sudo apt install -f

It downloaded and installed packages.

mchid
  • 43,546
  • 8
  • 97
  • 150
  • You can add the -f to dist-upgrade. But in my case, this will add the pkgProblemResolver error. Also, apt-get remove did not work with the same pkgProblemResolver error. dpkg --purge partly worked though. Sometimes it listed other packages as dependencies, which I just also removed the same way. And at the end apt-get dist-upgrade -f worked fine. – Albert Dec 27 '21 at 10:19
  • dpkg: error: --purge needs at least one package name argument – tribbloid Jan 09 '23 at 08:39
  • I had high hopes I would be able to find an answer in this thread. However, all of the items I tried failed, including this one. What finally got me over the hump actually was a response I got on the terminal to one of the commands, it said to run apt --fix-broken install - this fixed all the installed components and healed the repo list. I hope this helps someone! – Jay Imerman Aug 31 '23 at 17:37
5

To me, the problem looked like this

The following packages have unmet dependencies.
libglib2.0-dev : Depends: libglib2.0-0 (= 2.64.2-1~fakesync1) but 2.64.3-1~ubuntu20.04.1 is to be installed
                 Depends: libglib2.0-bin (= 2.64.2-1~fakesync1)

It was caused by a wrong selection of the kind of updates I wanted to download. I fixed it by opening Software & Updates, selecting Updates, and ensuring I had selected All updates for For other packages, subscribe to:. See picture below

enter image description here

I then run the usual apt update && apt dist-upgrade, and then I was able to install that lib.

5

I ran into this problem yesterday after someone rebooted during an OS version upgrade. None of the approaches worked above because of the sheer scale of the mess ups (~1500 packages).

To recover I went to /var/log/apt/history.log and looked at the last entry which has three very long lists describing what was being attempted when the OS upgrade failed. It consists of three lists "Upgrade:" "Install:" "Remove:" of the form:

Upgrade: package1:arch (old, new), package2:arch (old, new),
...

Take those three lists into your favourite regexp compatible editor, and replace the parentheses up to the comma with a newline. For the "Remove:" section append a "-" so you're left with lists like:

Install:
speech-dispatcher-espeak-ng:amd64
fdisk:amd64
libgoa-backend-1.0-1:amd64
...

Upgrade: speech-dispatcher-audio-plugins:amd64 ubuntu-settings:amd64 libmpc3:amd64 ...

Remove: qtdeclarative5-ubuntu-ui-toolkit-plugin:amd64- python-sip:amd64- gstreamer1.0-plugins-ugly-amr:amd64- ...

The "-" was a key learning because unless you can tell it to both install and remove you won't be able to work your way past many of the dependency cycles.

Keep a copy of this file so you can refer to it later, but make a new copy where you clean it up: remove all the extra lines of the file leaving just the package:arch lines.

Run apt using that resulting file packages.txt as follows

xargs -a packages.txt sudo apt install

This command will be all the adds/removes that the system intended to do before it got broken, and should represent a consistent set.

Assuming it finishes you can then complete anything missed with sudo apt install -f and sudo apt dist-upgrade.

Finish by creating a new list with just the "Install:" list of packages, pass them to apt-mark auto to mark the packages as automatically installed (the upgrade chose them, not you).

xargs -a installed.txt sudo apt-mark auto

I hope that helps someone else out there who thought their whole system was borked.

Greg
  • 1,413
  • This was the only solution that worked for me, thanks! I had to cancel an upgrade to bullseye and couldn't get it to continue. – Jakob Aug 16 '21 at 23:06
  • 1
    To save future visitors the regex noodling: \([^)]+\), should match (add spaces to front and back of that string), then replace with \n. – geerlingguy Oct 07 '21 at 20:40
  • Gosh, this is amazing! Saved my day! Bit of extra effort, need some simple python script to replace with new line as it was not working with nano, but this one worked for me. – adadion Aug 22 '22 at 12:29
3

This error can be caused by an incomplete package installation.

You have two options, 1) fix the broken installation, or 2) roll back (or remove) the broken installation.

Since it was not mentioned above, to roll back and remove the broken installation, exit synaptic (if you are still in it) and then enter these commands into a terminal:

sudo apt-get update       # Make sure your package list is up to date
sudo apt-get autoremove   # Removes "no longer required" packages

Then to confirm that the broken packages are gone, go back into synaptic and select, Edit | Fix broken packages and there should be no broken packages.

Note this does not fix the broken installation, it simply allows you to proceed again in synaptic with some other installation or removal, etc.

What happened was that you started a package installation and then part way through it, and after some dependencies had been installed, something went wrong, leaving unused dependent packages, and an incomplete install.