1

I installed clang-format on Ubuntu 18.04 LTS with sudo apt install clang-format and the installation was successful. I can execute clang-format-6.0 now, but when I use ClangFormat in vim, it tells me that "clang-format is not found". How can I fix the problem?

1

If you check what is contained in the package clang-format-6.0 (dpkg -L clang-format-6.0) you will find that it does not install clang-format into the /usr/bin directory. But you will find that it does install it to /usr/lib/llvm-6.0/bin instead.

One possible solution would be to add /usr/lib/llvm-6.0/bin to your PATH variable. Under this path clang-format is available. The command /usr/bin/clang-format-6.0 is just a symbolic link to it, so it should be equivalent to using clang-format-6.0. Why the package maintainer decided to not link /usr/bin/clang-format as well is not clear to me.

If you are unsure how to do that you may want to look it up here: https://help.ubuntu.com/community/EnvironmentVariables

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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