I had the same error: Recipe terminated with fatal error: spawn latexmk ENOENT.
The steps I took to solve my problem on macOS (Ventura 13.3.1), with MacTeX-2023 was:
- Within VSCode:
a. cmd+shift+P
, select Preferences: Open User Settings (JSON)
.
- Then within the json, paste the following within the {}:
"latex-workshop.latex.path": "/Library/TeX/texbin",
"latex-workshop.latex.tools": [
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
],
"env": {}
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
],
"env": {}
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
],
"env": {}
}
],
"latex-workshop.latex.recipes": [
{
"name": "pdfLaTeX",
"tools": [
"pdflatex"
]
},
{
"name": "latexmk ",
"tools": [
"latexmk"
]
},
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
{
"name": "pdflatex ➞ bibtex ➞ pdflatex`×2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
},
{
"name": "xelatex ➞ bibtex ➞ xelatex`×2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
}
]
Ensure "latex-workshop.latex.path": "/Library/TeX/texbin"
reflects your MacTeX installation. If you followed the default prompts when installing the .pkg of MacTeX, then the path I specified should be the same.
Restart Visual Studio Code.
a. I found that reloading the window with the Developer: Reload Window
command was not enough, I needed to quit Visual Studio Code and open again.
Try out the following in a test file, within a new .tex file (File > New File > test.tex
):
(I took this MWE from Overleaf)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Welcome to Overleaf --- just edit your LaTeX on the left,
% and we'll compile it for you on the right. If you open the
% 'Share' menu, you can invite other users to edit at the same
% time. See www.overleaf.com/learn for more info. Enjoy!
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[acronym]{glossaries}
\makeglossaries
\newglossaryentry{latex}
{
name=latex,
description={Is a mark up language specially suited for
scientific documents}
}
\newglossaryentry{maths}
{
name=mathematics,
description={Mathematics is what mathematicians do}
}
\newglossaryentry{formula}
{
name=formula,
description={A mathematical expression}
}
\newacronym{gcd}{GCD}{Greatest Common Divisor}
\newacronym{lcm}{LCM}{Least Common Multiple}
\begin{document}
\printglossary[type=\acronymtype]
The \Gls{latex} typesetting markup language is specially suitable
for documents that include \gls{maths}. \Glspl{formula} are
rendered properly an easily once one gets used to the commands.
Given a set of numbers, there are elementary methods to compute
its \acrlong{gcd}, which is abbreviated \acrshort{gcd}. This
process is similar to that used for the \acrfull{lcm}.
\clearpage
%\printglossary
\end{document}
- Finally, within VSCode:
- Select the TeX Workshop Extension in the left sidebar
- Select the drop-down arrow to the left of
Build LaTeX project
- Click the recipe:
Recipe: pdfLaTeX