2

The

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:
 build-essential : Depends: gcc (>= 4:9.2) but it is not going to be installed
                   Depends: g++ (>= 4:9.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

If dig deeper

❯ sudo apt-get install -f libgcc-9-dev
Reading package lists... Done
Building dependency tree
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:
 libgcc-9-dev : Depends: libitm1 (>= 9.3.0-10ubuntu2) but it is not going to be installed
                Depends: libatomic1 (>= 9.3.0-10ubuntu2) but it is not going to be installed
                Depends: liblsan0 (>= 9.3.0-10ubuntu2) but it is not going to be installed
                Depends: libtsan0 (>= 9.3.0-10ubuntu2) but it is not going to be installed
                Depends: libubsan1 (>= 9.3.0-10ubuntu2) but it is not going to be installed
                Depends: libquadmath0 (>= 9.3.0-10ubuntu2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
❯ sudo apt-get install -f libasan5 libatomic1 libgcc-s1
Reading package lists... Done
Building dependency tree
Reading state information... Done
libgcc-s1 is already the newest version (10.1.0-2ubuntu1~18.04).
libgcc-s1 set to manually installed.
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:
 libatomic1 : Depends: gcc-10-base (= 10-20200411-0ubuntu1) but 10.1.0-2ubuntu1~18.04 is to be installed
E: Unable to correct problems, you have held broken packages.

How to solve this dependency chain problem? force it to use the latest packages or downgrade to the recommended versions?

1
  • 2
    It's much easier to downgrade to the recommended versions. Remember that Ubuntu is a snapshot distro - all the versions sync every 6 months. When you wander away from that, you get held broken packages (version conflicts).
    – user535733
    Jul 2 '20 at 21:10
2

As @user535733 mentioned, downgrading is much easier. I manage to downgrade all the dependencies and install the correct verison of gcc. The trick is to make use of aptitude, that offers richer features than apt.

sudo apt install aptitude
sudo aptitude update && sudo aptitude install build-essential

It gives me:

      Install the following packages:
1)      tcc [0.9.27-8 (focal)]

      Keep the following packages at their current version:
2)      build-essential [Not Installed]
3)      g++ [Not Installed]
4)      g++-9 [Not Installed]
5)      gcc [Not Installed]
6)      gcc-9 [Not Installed]
7)      libatomic1 [Not Installed]
8)      libgcc-9-dev [Not Installed]
9)      libitm1 [Not Installed]
10)     liblsan0 [Not Installed]
11)     libquadmath0 [Not Installed]
12)     libstdc++-9-dev [Not Installed]
13)     libtsan0 [Not Installed]
14)     libubsan1 [Not Installed]

Which is not what we want, so type n

Then aptitude will propose another solution, that looks like this:

The following actions will resolve these dependencies:

     Downgrade the following packages:
1)     gcc-10-base [10.1.0-2ubuntu1~18.04 (now) -> 10-20200416-0ubuntu1 (focal)]
2)     libcc1-0 [10.1.0-2ubuntu1~18.04 (now) -> 10-20200416-0ubuntu1 (focal)]
3)     libgcc-s1 [10.1.0-2ubuntu1~18.04 (now) -> 10-20200416-0ubuntu1 (focal)]
4)     libgcc1 [1:10.1.0-2ubuntu1~18.04 (now) -> 1:10-20200416-0ubuntu1 (focal)]
5)     libgomp1 [10.1.0-2ubuntu1~18.04 (now) -> 10-20200416-0ubuntu1 (focal)]
6)     libstdc++6 [10.1.0-2ubuntu1~18.04 (now) -> 10-20200416-0ubuntu1 (focal)]



Accept this solution? [Y/n/q/?] Y

We can accept this plan and then confirm the installtion.

Setting up build-essential (12.8ubuntu1) ...

When you see above line, it's done! Congratulations!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.