2

I deleted clang. I tried to use apt to uninstall clang, and then re-install it but I get this error:

Setting up clang (1:3.8-33ubuntu3.1) ...
update-alternatives: error: alternative path /usr/bin/clang++ doesn't 
exist
dpkg: error processing package clang (--configure):
 subprocess installed post-installation script returned error exit 
status 2
Errors were encountered while processing:
 clang
E: Sub-process /usr/bin/dpkg returned an error code (1)

I've tried also using apt to remove llvm and reinstall it knowing it should also install clang.

I'm using Ubuntu 16.04, since further versions are un-workingly buggy for me.

Here's some more info:

main@ws001:~$ whereis clang
clang: /usr/bin/clang #this is obviously broken
main@ws001:~$ which clang

apt-cache depends clang

clang
  Depends: clang-3.8
  Breaks: <clang-3.2>
  Breaks: <clang-3.3>
  Breaks: <clang-3.4>
  Breaks: clang-3.5
  Replaces: clang
  Replaces: <clang-3.2>
  Replaces: <clang-3.3>
  Replaces: <clang-3.4>
  Replaces: clang-3.5
  • You probably need to re-install the underlying dependency package (likely clang-3.8 - but confirm with apt-cache depends clang) – steeldriver May 17 '17 at 14:05
1

You could reinstall the packages with the --force-overwrite flag:

dpkg -i --force-overwrite /var/cache/apt/archives/clang*

Look at the cache for older versions before you use clang*.

  • dpkg: error processing package clang (--install): subprocess installed post-installation script returned error exit status 2 – curious student May 17 '17 at 14:22
  • You could search for the failing command in /var/lib/dpkg/info/clang.{postinst,prerm}. I cannot reproduce your error with the provided rm command. Did you do something else? – ctx May 17 '17 at 15:11
0

The problem is Clang is already installed but linked up with other name.

If that code gives you such error:

cd /var/lib/dpkg/info/
./clang.postinst
update-alternatives: ошибка: альтернативный путь /usr/bin/clang++ не существует

The solution will be to edit clang.postinst. Change that:

update-alternatives --quiet \
   --install /usr/bin/c++ \
        c++ \
        /usr/bin/clang++ \
        $prio

update-alternatives --quiet \
    --install /usr/bin/cc \
        cc \
        /usr/bin/clang \
        $prio

To that:

update-alternatives --quiet \
   --install /usr/bin/clang++ \
        clang++ \
        /usr/bin/c++ \
        $prio

update-alternatives --quiet \
    --install /usr/bin/clang \
        clang \
        /usr/bin/cc \
        $prio

Than run it and test clang:

./clang.postinst

clang
clang: fatal error: no input files
compilation terminated.
New contributor
DobroSun is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
-1

Solved through OS re-install. If anyone encounters this and manages to solve it, please do let me know how.

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.