I updated my texlive to 2022 recently and found that the auto-compilation command in tex-mode running latexmk -pdf -pdflatex=xelatex --synctex=1 -interaction=nonstopmode -file-line-error file.tex throws this error:

/bin/sh: latexmk: command not found
TeX Output exited abnormally with code 127 at Mon May  9 15:51:01

My attempted solutions:

  1. I am pretty sure the new path of texlive2022 was added to my $PATH, I also tried echo $PATH in the built-in shell of Emacs, it also gives the correct path names.
  2. I've tried the answer in Trying to run a linux program in Emacs: command not found, i.e., add the path to ~/.profile, but it doesn't work as well.
  3. I also checked out using M-x getenv path, and it does contain the path inside emacs.

1 Answer 1


In fact, the third attempted solution works.

Put a line in config.el

(setenv "PATH" "...")

actually works.

  • Did you set PATH to something different from the environment value? If yes, what did you change?
    – NickD
    Commented May 10, 2022 at 6:06
  • I set it to be precisely the environment value outside (its original value is different from that).
    – Cong Wen
    Commented May 10, 2022 at 21:29

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.