1

I need to add the following repo in ubuntu 16.04:

deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty main

I attempted to add that repo by typing following command:

sudo add-apt-repository "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty main"

I want to add that repo because I want to install packages from there.

I see that after the add-apt-repository command there is an entry added in /etc/apt/sources.list

but when I am trying to install the package using sudo apt-get install clang-3.4 I still get error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package clang-3.4 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'clang-3.4' has no installation candidate

  • Did you run sudo apt-get update after adding the repository? – muru Jun 11 '20 at 07:52
  • That repository is for ubuntu 14.04 (trusty tahr ) . You have to either change the "trusty" to "xenial" or look for the repository that's compatible with ubuntu 16.04 (xenial xerus) – Parsa Mousavi Jun 11 '20 at 07:55
  • You have to add this repo : "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main" – Parsa Mousavi Jun 11 '20 at 07:56
  • @ParsaMousavi. Thanks. I added as you said. But when I did sudo apt-get update , I got following message : W: GPG error: https://apt.llvm.org/xenial llvm-toolchain-xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 15CF4D18AF4F7421 W: The repository 'http://apt.llvm.org/xenial llvm-toolchain-xenial InRelease' is not signed. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use. N: See apt-secure(8) manpage for repository creation and user configuration details. – AlphaParticle Jun 11 '20 at 08:07
  • After that when I typed sudo apt-get install clang-3.4 I got the same error. – AlphaParticle Jun 11 '20 at 08:09
  • Does this work for you : "sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421 " ? I tried it and the public key successfully got imported. – Parsa Mousavi Jun 11 '20 at 08:17
  • @ParsaMousavi. Thanks. I did that. Now there is no warning when I do sudo apt-get update, but still when I do sudo apt-get install clang-3.4, I get the same error. And by the way the package clang-3.4 is in trusty only, not in xenial. – AlphaParticle Jun 11 '20 at 08:28
  • Use the tab completion feature to see what versions of clang is available in xenial . Also you can search through all of the clang packages via "apt search clang ". – Parsa Mousavi Jun 11 '20 at 08:29

1 Answers1

1
  1. Remove the trusty repository that you mistakenly added to Ubuntu 16.04. This incompatible repository is causing NO_PUBKEY errors when you try to update with sudo apt update, and there is a xenial clang 3.4 package available at http://launchpadlibrarian.net/, so you should install the xenial clang 3.4 package instead of the trusty package.

     sudo add-apt-repository --remove "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty main"  
     sudo apt update  
     sudo apt remove clang-3.4 
    
  2. Download clang-3.4_3.4.2-16ubuntu3_amd64.deb for Ubuntu 16.04 from http://launchpadlibrarian.net/.

    cd Desktop/
    wget http://launchpadlibrarian.net/227310349/libllvm3.4_3.4.2-16ubuntu3_amd64.deb http://launchpadlibrarian.net/227310340/libclang-common-3.4-dev_3.4.2-16ubuntu3_amd64.deb http://launchpadlibrarian.net/227310332/clang-3.4_3.4.2-16ubuntu3_amd64.deb
    
  3. Install clang 3.4 with the following command:

    sudo apt install --no-install-recommends ./libllvm3.4_3.4.2-16ubuntu3_amd64.deb ./libclang-common-3.4-dev_3.4.2-16ubuntu3_amd64.deb ./clang-3.4_3.4.2-16ubuntu3_amd64.deb
    
karel
  • 114,770
  • I did as you said but I received this error: Note, selecting 'clang-3.4' instead of './clang-3.4_3.4.2-16ubuntu3_amd64.deb' 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: – AlphaParticle Jun 12 '20 at 18:12
  • The following packages have unmet dependencies: clang-3.4 : Depends: libclang1-3.4 (= 1:3.4.2-16ubuntu3) but 1:3.4-1ubuntu3 is to be installed Depends: libclang-common-3.4-dev (= 1:3.4.2-16ubuntu3) but it is not installable Recommends: llvm-3.4-dev but it is not installable – AlphaParticle Jun 12 '20 at 18:12
  • Above is the error split into 2 comments. I received the above error after step 3 of your post. – AlphaParticle Jun 12 '20 at 18:37