8

After trying to install libclang-dev with sudo apt-get install -y libclang-dev i receive this error:

The following packages have unmet dependencies:
 libclang-dev : Depends: libclang-10-dev (>= 10~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

When I try the solution:

 $ wget https://apt.llvm.org/llvm.sh
 $ chmod +x llvm.sh
 $ sudo ./llvm.sh 12

Thiss occurs:

The following packages have unmet dependencies:
 clang-12 : Depends: libclang-common-12-dev (= 1:12.0.1~++20210511012537+24535af52ae1-1~exp1~20210510233243.87) but it is not going to be installed
 clangd-12 : Depends: libclang-common-12-dev (= 1:12.0.1~++20210511012537+24535af52ae1-1~exp1~20210510233243.87) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

The output of sudo apt-cache policy libc6

libc6:
  Installed: 2.31-0ubuntu9.2
  Candidate: 2.31-0ubuntu9.2
  Version table:
 *** 2.31-0ubuntu9.2 500
        500 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.31-0ubuntu9 500
        500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
  • 1
    You seem to have two (almost) completely separate issues: 1) You have broken clang-10 by adding non-Ubuntu sources and packages. Remove them. 2) You have tried to bolt new clang-12 packages onto an older 20.04 system. That doesn't work. Pick between clang-10 and clang-12, use the correct release of Ubuntu for that version of Clang, and stick to the Ubuntu repositories that are built for that version of Clang. – user535733 May 11 '21 at 17:49
  • 1
  • Also please note that llvm 12 installs normally on fresh 20.04 LTS VM using your script. So you have to fix official repositories first. Please add output of apt-cache policy libc6 llvm clang to the question. – N0rbert May 11 '21 at 18:14
  • @N0rbert Can you be more specific with fixing official repositories? My sources.list file is as here https://gist.github.com/ishad0w/788555191c7037e249a439542c53e170 – vulkanovski May 11 '21 at 18:17
  • 1
    What about other sources located within /etc/apt/sources.list.d/ ? – user535733 May 11 '21 at 18:23
  • Please share the output of above requested command apt-cache policy libc6 llvm clang and grep "^deb\ " -r /etc/apt/ --include=*.list . If long - use pastebin. – N0rbert May 11 '21 at 18:25
  • @user535733 google-chrome.list, team.list, vscode.list with .save files – vulkanovski May 11 '21 at 18:27
  • @N0rbert So the output for cache policy command is: https://pastebin.com/E73k8PuZ. For next one is: https://pastebin.com/WwWDGqUV – vulkanovski May 11 '21 at 19:01
  • @N0rbert Seems like I don't have llvm and clang installed at all? – vulkanovski May 11 '21 at 19:02
  • @user535733 The package "libc6" is probably broken: The following packages have unmet dependencies: libc6-i386 : Depends: libc6 (= 2.31-0ubuntu9.2) but 2.31-0ubuntu9.3 is to be installed. How to manage that? – vulkanovski May 11 '21 at 20:11

4 Answers4

11

You have to revert libc6 library to the normal version using command below:

sudo apt-get install libc6=2.31-0ubuntu9.2 libc6:i386=2.31-0ubuntu9.2
N0rbert
  • 99,918
3

For me it solved

sudo apt --fix-broken install
sudo apt-get update

And then installing with

sudo dpkg -i rstudio-specific-version.deb
2

I got same problem. I have run this steps (no idea what they did - I'm new on this, but works for me)

sudo apt-get autoremove

sudo apt-get autoclean

sudo apt-get update

sudo apt-get -f install

Willy
  • 21
-1

I was getting this message:

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 solved my issue with this solution (formatting my own):

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.