0

I'm trying to setup emacs to use the clang-format package. I have installed the clang-format package from MELPA and also have clang-format-10 (apt install only installs version 6 on Ubuntu) installed on my local machine. I also have the following lines in ~/.emacs:

(require 'clang-format)
(setq clang-format-style "file")
(setq exec-path (append exec-path '("/usr/bin/clang-format-10")))

I added the last last line because M-x clang-format-region throws the error:

Searching for program: No file or directory, clang-format

However, the clang-format package appears to still be looking for a clang-format binary without the version suffix. Also, it's worth noting I made an alias in my ~/.bashrc so clang-format points to clang-format-10, however that doesn't help me in emacs.

1 Answer 1

1

First of all, .bashrc doesn’t help since it’s for non-login shell if I remember correctly.

Secondly, I believe a “path” in exec-path should end with “bin”, like it would be in environment variable PATH. Also, /usr/bin should already be there, thus no need to add.

What you should have done is adding a symlink. You can do:

  • sudo ln -sf clang-format-10 /usr/bin/clang-format if you have sudo access, OR
  • ln -sf /usr/bin/clang-format-10 ~/bin/clang-format and add /home/yourusername/bin to exec-path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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