0

When I open a new tex file and hit C-c C-e <RET> to create document environment, the message buffer shows

TeX-search-files-by-type: No TeX trees available; configure ‘TeX-tree-roots’.

It will then exit the environment input procedure and there is no automatically created \begin{document} \end{document}. How do I deal with this problem? This has not happened before.

I am using an M1 MacBook Pro running macOS Monterey 12.0.1
Emacs version: 27.2
AUCTeX version: 13.0.14

Edit: The problem appears only when using GUI. Emacs in terminal works fine.

4
  • I cannot replicate this under linux: same emacs and AUCTeX versions. Commented Nov 10, 2021 at 22:02
  • I suspect Emacs doesn't find the program kpsewhich. You can check that by inserting (executable-find "kpsewhich") in scratch buffer, putting the point after the ) and hitting C-x C-e. Commented Nov 13, 2021 at 7:46
  • @ArashEsbati Thank you. You are right. Emacs GUI does not find kpsewhich. However, emacs in terminal is able to find it and there is no problem with creating a new environment. I will try to fix the path problem by myself.
    – 1615244
    Commented Dec 5, 2021 at 20:12
  • @FranBurstall The problem is related to macOS. See my answer below.
    – 1615244
    Commented Dec 5, 2021 at 21:02

1 Answer 1

1

It turns out that the issue is, as @ArashEsbati suggested, that Emacs is not able to find kpsewhich in GUI. It is a macOS specific issue, as discussed in this problem. We may set the environment PATH in GUI to be the same as in terminal by using the package exec-path-from-shell. With use-package, adding the following to my init file solved the problem.

(use-package exec-path-from-shell
  ;; Get environment variables such as $PATH from the shell
  :ensure t
  :config (when (memq window-system '(mac ns x))
        (exec-path-from-shell-initialize)))

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.