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
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 thebuild-essential
metapackage for 20.04 installed, so might be a better try to purge it, then install. – Hannu Mar 30 '24 at 08:52$
prompt, trysudo apt purge build-essential
, hit enter. If that works replacepurge
withinstall
and see if that works without errors. – Hannu Mar 30 '24 at 09:13apt policy gcc-11-base
– steeldriver Mar 30 '24 at 10:20jammy/main
,jammy-updates/main
andjammy-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