25

I upgraded my Linux box from Ubuntu 18.04 to 20.04.

I need to install the clang suite of compilers and the apt command is giving me errors. I've searched many possible solutions but so far none of the recommendations I have found to solve similar problems have helped. Here is what I get when I try apt install clang :

➜ ~ sudo apt-get install -f clang
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: clang : Depends: clang-10 (>= 10~) but it is not going to be installed E: Unable to correct problems, you have held broken packages. ➜ ~

I've done all sorts of apt-get update and apt-get upgrade. I've also tried to list every package one after the other, but the list keeps growing and it hasn't solved the issue.

Edit: Following @Martin Konrad I tried aptitude:

➜  ~ sudo aptitude install clang
The following NEW packages will be installed:
  clang clang-10{ab} lib32gcc-s1{ab} lib32gcc1{ab} lib32stdc++6{ab} 
  libc6-i386{a} libclang-common-10-dev{ab} libclang-cpp10{ab} libffi-dev{a} 
  libobjc-9-dev{ab} libobjc4{ab} libomp-10-dev{a} libomp5-10{a} libpfm4{a} 
  libz3-4{a} libz3-dev{a} llvm-10{a} llvm-10-dev{ab} llvm-10-runtime{a} 
  llvm-10-tools{a} python3-pygments{a} 
0 packages upgraded, 21 newly installed, 0 to remove and 9 not upgraded.
Need to get 58.4 MB of archives. After unpacking 381 MB will be used.
The following packages have unmet dependencies:
 lib32stdc++6 : Depends: gcc-10-base (= 10-20200411-0ubuntu1) but 10-20200416-0ubuntu1~18.04 is installed
 libobjc4 : Depends: gcc-10-base (= 10-20200411-0ubuntu1) but 10-20200416-0ubuntu1~18.04 is installed
 lib32gcc-s1 : Depends: gcc-10-base (= 10-20200411-0ubuntu1) but 10-20200416-0ubuntu1~18.04 is installed
 clang-10 : Depends: libclang1-10 (= 1:10.0.0-4ubuntu1) but 1:10.0.1~++20200519100828+f79cd71e145-1~exp1~20200519201452.38 is installed
 lib32gcc1 : Depends: gcc-10-base (= 10-20200411-0ubuntu1) but 10-20200416-0ubuntu1~18.04 is installed
 libclang-cpp10 : Depends: libllvm10 (= 1:10.0.0-4ubuntu1) but 1:10.0.1~++20200519100828+f79cd71e145-1~exp1~20200519201452.38 is installed
 libobjc-9-dev : Depends: gcc-9-base (= 9.3.0-10ubuntu2) but 9.3.0-11ubuntu0~18.04.1 is installed
                 Depends: libgcc-9-dev (= 9.3.0-10ubuntu2) but 9.3.0-11ubuntu0~18.04.1 is installed
 libclang-common-10-dev : Depends: libllvm10 (= 1:10.0.0-4ubuntu1) but 1:10.0.1~++20200519100828+f79cd71e145-1~exp1~20200519201452.38 is installed
 llvm-10-dev : Depends: libllvm10 (= 1:10.0.0-4ubuntu1) but 1:10.0.1~++20200519100828+f79cd71e145-1~exp1~20200519201452.38 is installed
The following actions will resolve these dependencies:

      Keep the following packages at their current version:
1)      clang [Not Installed]                              
2)      clang-10 [Not Installed]                           
3)      lib32gcc-s1 [Not Installed]                        
4)      lib32gcc1 [Not Installed]                          
5)      lib32stdc++6 [Not Installed]                       
6)      libclang-common-10-dev [Not Installed]             
7)      libclang-cpp10 [Not Installed]                     
8)      libobjc-9-dev [Not Installed]                      
9)      libobjc4 [Not Installed]                           
10)     llvm-10-dev [Not Installed]                        

      Leave the following dependencies unresolved:         
11)     llvm-10 recommends llvm-10-dev                     



Accept this solution? [Y/n/q/?] Y
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
   

Its solution is to not install effectively.

2
  • I never got it fixed. Instead I compiled clang from scratch on my own and that worked.
    – Michel
    Commented Jul 12, 2020 at 4:09
  • Have the same issue. Have no idea how to solve.
    – Yuki
    Commented Feb 6, 2021 at 19:36

4 Answers 4

10

You are actually pretty close with the aptitude suggestion. If you look at what is installed, you see that the Ubuntu 18 versions of those packages are still present.

When I did sudo aptitude install clang, I got the same message as shown, but then typed 'n'. Aptitude then offers another solution, which is to offer to 'downgrade' to gcc 9. Allow it to do that, and let it return to the command prompt. Then then do sudo apt install clang and you'll get clang-10.

1
  • run sudo apt install aptitude first :) Commented Sep 21, 2022 at 21:29
7

Personally I encountered this issue and solved it by installing LLVM using the Automatic installation script they mention in their apt packages page.

2
  • 1
    This is the way! Commented Apr 15, 2021 at 13:50
  • 1
    bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
    – tejasvi
    Commented Dec 20, 2021 at 3:30
2

Sounds like you are running into conflicts for some reason. The root cause might be that you enabled non-Ubuntu package repositories after upgrading that aren't 100% compatible with Ubuntu 20.04? If so consider removing them from /etc/apt/sources.list.d/ and run apt update.

If that doesn't help, I would recommend running aptitude interactively. It proposes solutions and allows you to resolve them in a semi-automatic way. You might also want to keep an eye on "held" packages. It often helps to upgrade them. To do so start aptitude in interactive mode and press Shift+U, then G twice.

1
  • 3
    How do I know which repositories to remove from that directory? I installed aptitude and will try.
    – Michel
    Commented Jun 16, 2020 at 23:38
1

I managed to fix this by manually downgrading two key packages.

sudo apt install libclang1-10=1:10.0.0-4ubuntu1 libllvm10=1:10.0.0-4ubuntu1

The full aptitude command then let me continue but removed some packages that should be noted.

The following NEW packages will be installed:
  clang clang-10{a} libclang-common-10-dev{a} libclang-cpp10{a} libomp-10-dev{a} libomp5-10{a} 
  llvm-10{a} llvm-10-dev{a} llvm-10-runtime{a} llvm-10-tools{a} 
The following packages will be REMOVED:
  libomp-11-dev{a} libomp5-11{a} 
1
  • In my case, the problem was with offending libc6. I had to downgrade and then everything worked. Yes it did sound scary, but worked out in the end. I tried to add the repo from apt.llvm.org but it did not fix the dependency problem. However, when I downgraded libc6, apt happily installed clang-13. First I had to clean up all of the i386 stuff, then downgrade libc6=2.31-0ubuntu9.3 to libc6=2.31-0ubuntu9.2. Use apt remove libc6:i386; apt install libc6=2.31-0ubuntu9.2; apt install clang. Then you may reinstall any i386 packages (wine32 in my case).
    – egridasov
    Commented May 14, 2021 at 12:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .