VisualStudioCode (with LatexWorkshop) gives spawn latexmk ENOENT, but latex is in the path. (MacOs)

3.4k views Asked by At

I'm unable to use LatexWorkshop+VSCode as I'm getting the known error LaTeX fatal error: spawn latexmk ENOENT, . PID: undefined.. I'm using a fresh install of TexLive (through MacTex on MacOs). Yet, although /Library/Tex/texbin is in my path (here is the output from echo $PATH):

/Users/myusername/.nvm/versions/node/v11.10.0/bin:/Users/myusername/miniconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Users/myusername/.fig/bin.

Here are some other relevant system info.

> which perl
/usr/local/bin/perl
> which tlmgr
/Library/TeX/texbin/tlmgr
> which latexmk
/Library/TeX/texbin/latexmk

So, it seems that latex is in my path, but when I try to compile I inevitably get the following error:

LaTeX build process spawned. PID: undefined.
LaTeX fatal error: spawn latexmk ENOENT, . PID: undefined.
Does the executable exist? $PATH: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Does the executable exist? $Path: undefined
The environment variable $SHELL: /bin/zsh

I even tried to force in LatexWorkshop settings by using the following in latexmk"env": { "TEXMFHOME": "/Library/TeX/texbin/latexmk" }

I already restarted VSCode several times (as well as the OS), and tried other solutions (e.g. these) but I just can't make this work. Can anyone help me here?

1

There are 1 answers

0
shunliang On

I think there are two methods you can try.

  1. Use terminal code to launch a VS Code, rather than Finder. See: https://github.com/James-Yu/LaTeX-Workshop/issues/1414

  2. Use "PATH" rather than "TEXMFHOME" in env, see: https://github.com/James-Yu/LaTeX-Workshop/issues/1742. I don't know what "TEXMFHOME" means although it is an example in the LaTeX Workshop wiki.

Both methods are tried by myself and succeed.