Fix "Could not calculate the upgrade" on Ubuntu 24.04 to 26.04
Fix "Could not calculate the upgrade" (24.04 to 26.04): find the Broken package in /var/log/dist-upgrade/apt.log, the known lintian case and its workaround.
Could not calculate the upgradeAn unresolvable problem occurred while calculating the upgrade.If do-release-upgrade prints these two lines on Ubuntu 24.04 LTS going to 26.04 LTS, the package that blocks the calculation is recorded under /var/log/dist-upgrade/. The message on screen does not name it.
[1] Read the end of main.log for the failure line. In the main.log of a Launchpad report (Bug #2150319) the resolver's stop message looked like this:
# tail -n 25 /var/log/dist-upgrade/main.log[2] Find the blocking package in apt.log. In the same report the line that pointed at the cause was a Broken entry in apt.log. The package after Broken is the one the resolver could not upgrade; what follows Depends on is the dependency it needs.
# grep -i broken /var/log/dist-upgrade/apt.logThe line quoted in the report:
Broken lintian:amd64 Depends on libfile-libmagic-perl:amd64 < none | 1.23-2build2 @un uH >The @un uH at the end is apt's notation for a dependency that is not installed. The line says lintian needs a new dependency and the resolver did not select it. In that case the installed lintian was the 24.04 version (2.117.0ubuntu1.4) and the 26.04 version newly required libfile-libmagic-perl.
The report also had an apt-clone system-state archive and a screen.log attached besides main.log and apt.log. Which file shows the cause can differ per case, so if Broken finds nothing, read the earlier errors in main.log.
[2-1] If you see the same lintian line, the temporary workaround an Ubuntu developer suggested in that report is to purge lintian before the upgrade and reinstall it afterwards. lintian is a package-checking tool, not a server service, but check with apt-mark showmanual | grep lintian that you did not install it on purpose.
# apt purge lintian# do-release-upgrade# apt install lintianIf you cannot remove lintian, the same report has another user's case: they purged libmagic-mgc and libmagic1t64, rebooted, reinstalled them and ran the upgrade again, which got through (a user report, not an official fix). Purging libmagic1t64 can remove other packages with it, so do not confirm until you have read the removal list apt shows.
In the same report the ubuntu-release-upgrader fix (a quirk in DistUpgrade/DistUpgradeQuirks.py) is marked "Fix Released" for the Resolute (26.04) task. The fix went into the 26.04-side upgrade tool, which do-release-upgrade is understood to download when it runs, but that point was not checked against official documentation. There is no evidence that running full-upgrade on the 24.04 packages delivers this fix. If the same Broken line still appears, use the workaround above. Which tool version first carries the fix could not be confirmed either.
[3] List and unhold any held packages preventing dependency resolution.
# apt-mark showhold# apt-mark unhold <package-name>[4] Purge conflicting third-party PPAs and revert their packages.
# apt -y install ppa-purge# ppa-purge ppa:<ppa-owner>/<ppa-name>[5] Bring the current release fully up to date and fix broken dependencies.
# apt update# apt -y full-upgrade# apt -y --fix-broken install[6] Run the release upgrade again.
# do-release-upgrade