0

I have upgraded Ubuntu from 20.04lts to 22.04lts. However it seems that gcc, g++ and gfortran have disappeared from the system. I have tried:

sudo apt install gcc

but got the error:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies: cpp-11 : Depends: gcc-11-base (= 11.4.0-1ubuntu1~22.04) but 11.4.0-2ubuntu1~20.04 is to be installed gcc-11 : Depends: gcc-11-base (= 11.4.0-1ubuntu1~22.04) but 11.4.0-2ubuntu1~20.04 is to be installed Depends: libgcc-11-dev (= 11.4.0-1ubuntu1~22.04) but it is not going to be installed E: Unable to correct problems, you have held broken packages.

I have tried

sudo apt install gcc-11-base

But it says that it is already installed to the latest version and trying to install libgcc-11-dev leads to a seemingly never-ending chain of unmet dependencies.

What should I do?

EDIT As requested this is the output of policy gcc-11-base

gcc-11-base:
  Installed: 11.4.0-2ubuntu1~20.04
  Candidate: 11.4.0-2ubuntu1~20.04
  Version table:
 *** 11.4.0-2ubuntu1~20.04 100
        100 /var/lib/dpkg/status
     11.4.0-1ubuntu1~22.04 500
        500 http://it.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
     11.2.0-19ubuntu1 500
        500 http://it.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
mattiav27
  • 875
  • cpp-11 : Depends: gcc-11-base (= 11.4.0-1ubuntu1~22.04) but 11.4.0-2ubuntu1~20.04 is to be installed - try uninstall (you seem to have 20.04 version installed) and then install (should get you the 22.04 version). Actually, you might have had the build-essential metapackage for 20.04 installed, so might be a better try to purge it, then install. – Hannu Mar 30 '24 at 08:52
  • @Hannu can you show the commands? – mattiav27 Mar 30 '24 at 09:10
  • Open a terminal, at the $ prompt, try sudo apt purge build-essential, hit enter. If that works replace purge with install and see if that works without errors. – Hannu Mar 30 '24 at 09:13
  • Did you add the focal toolchain-r ppa to your 20.04 system - and if so did you remember to disable it before upgrading? – steeldriver Mar 30 '24 at 09:59
  • @steeldriver no I didn't add any ppa – mattiav27 Mar 30 '24 at 10:10
  • 1
    ... please [edit] your question to include the output of apt policy gcc-11-base – steeldriver Mar 30 '24 at 10:20
  • @steeldriver added – mattiav27 Mar 30 '24 at 12:18
  • 1
    You are using gcc from Ubuntu 20.04 in Ubuntu 22.04 appears to be your problem. The repositories need to be matched to your Ubuntu release. For this reason follow the duplicate links in the same order that they are listed. First of all restore your software sources back to your default Ubuntu 22.04 repositories. – karel Mar 30 '24 at 13:04
  • FWIW I don't see any problem with the repositories shown now (jammy/main, jammy-updates/main and jammy-security/main) so I think rather the problem is what was installed from a non-official repository (likely the toolchain-r ppa as I mentioned previously) before the update to jammy – steeldriver Mar 30 '24 at 13:48

0 Answers0