1

Problem

I am using latexkm to compile .tex documents, and recently I got this error while compiling:

Running `latexmk' on `AF2021_serie5' with ``latexmk -bibtex-cond -pdf -synctex=1 AF2021_serie5''
Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 17 Apr. 2020, version: 4.69a.
Latexmk: applying rule 'biber AF2021_serie5'...
Rule 'biber AF2021_serie5': The following rules & subrules became out-of-date:
      'biber AF2021_serie5'
------------
Run number 1 of rule 'biber AF2021_serie5'
------------
------------
Running 'biber  "AF2021_serie5"'
------------
sh: biber : commande introuvable
Latexmk: Errors, so I did not complete making targets
Collected error summary (may duplicate other messages):
  biber AF2021_serie5: Could not open biber log file for 'AF2021_serie5'
Latexmk: Use the -f option to force complete processing,
 unless error was exceeding maximum runs, or warnings treated as errors.

TeX Output exited abnormally with code 12 at Tue Oct  6 21:15:40

I am apparently not the only one to have had this problem (1) but the solution in the link did not fix it for me.

Solutions tried that do not fix the problem

I figured that

  1. I am using zsh as my default shell when I open a terminal, while emacs seems to load sh.
  2. Compiling the .tex files with latexmk from the terminal does not generate this error.
  3. Launching emacs with SHELL=/bin/zsh emacs and then using C-c C-c latexmkdoes not generate this error.
  4. Adding
(setq-default shell-file-name "/bin/zsh")
(setq-default explicit-shell-file-name "/bin/zsh")

to my .emacs does not fix the problem; however when I click on Run Shell Interactively, I can compile the .texwith latexmk and it does not generate this error.

  1. Adding
(setq tex-shell-file-name "/bin/zsh")
(setq TeX-shell "/bin/zsh")

to my .emacs does not fix the error. It still seems that latexmk is ran through /bin/sh.

Additional information

Part of my .emacs:

;; == AucTeX == ;;
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq preview-auto-cache-preamble t) ; stop preview pestering
; (setq-default TeX-master nil)
(add-hook 'LaTeX-mode-hook 'visual-line-mode) ; Word wrapping
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(setq LaTeX-electric-left-right-brace t) ; Automatic close parenthesis
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(setq TeX-PDF-mode t) ; Compile as a PDF
(setq reftex-ref-macro-prompt nil) ; Disable annoying reference prompt screen

;; == RefTeX == ;;
(setq reftex-bibliography-commands '("bibliography" "nobibliography" "addbibresource"))

;; === LatexMK - automatically recompile and run bibtex ===;;
(add-hook 'LaTeX-mode-hook (lambda ()
  (push
    '("latexmk" "latexmk -bibtex-cond -pdf -synctex=1 %s" TeX-run-TeX nil t
      :help "Run latexmk on file")
    TeX-command-list)))
(add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "latexmk")))

result of which biber (from zsh)

/usr/bin/vendor_perl/biber

result of which biber (from sh)

/usr/bin/vendor_perl/biber

Final question, I guess

What can I add to my .emacs so that latexmk is ran inside of zsh instead of sh?

  • What happens if you run `latexmk` in a terminal that is running `sh`? – NickD Oct 07 '20 at 14:58
  • It actually works, I don't have any error. – Laurent Hayez Oct 08 '20 at 12:07
  • Then it has to be `exec-path` that's wrong: what is its value? – NickD Oct 08 '20 at 13:23
  • @NickD Using `M-x describe-variable exec-path`, it returns `exec-path is a variable defined in ‘C source code’. Its value is ("/usr/bin/vendor_perl" "/usr/local/bin" "/usr/local/sbin" "/usr/bin" "/usr/lib/jvm/default/bin" "/usr/lib/emacs/27.1/x86_64-pc-linux-gnu") Original value was ("/usr/local/bin" "/usr/local/sbin" "/usr/bin" "/usr/lib/jvm/default/bin" "/usr/lib/emacs/27.1/x86_64-pc-linux-gnu")` – Laurent Hayez Oct 14 '20 at 08:04

1 Answers1

1

I don't think it has anything to do with zsh vs sh. I believe it has to do with subprocessess of emacs not having the path required to find the biber executable, whereas interactive shells apparently do.

Try adding the path to exec-path: evaluate the following form

(add-to-list 'exec-path "/usr/bin/vendor_perl")

and try your latexmk run. If that works, add the line to your init file, restart emacs and test again.

EDIT: The doc string for exec-path says:

List of directories to search programs to run in subprocesses. Each element is a string (directory name) or nil (try default directory).

so it should resolve the sh: biber : commande introuvable done in the subshell, particularly since you say that in an interactive sh, doing which biber finds the executable. Not sure why you are still having problems.

NickD
  • 27,023
  • 3
  • 23
  • 42
  • Unfortunately, this does not solve the problem. Adding `(add-to-list 'load-path "/usr/bin/vendor_perl/")`does not fix it either. I still get the same weird error that it is `sh` that tries to run biber?? I don't have a `.latexmkrc` file. Could the error come from this? – Laurent Hayez Oct 07 '20 at 06:20
  • I thought thererror was this: "sh: biber : commande introuvable" – NickD Oct 07 '20 at 14:38
  • Do not add it to `load-path` unless you have lisp libraries in there (which you should not have). – NickD Oct 07 '20 at 14:38