Recipe terminated with fatal error: spawn latexmk ENOENT

I had the same problem. The root cause was: (1) software’s bin folder missing from PATH; (2) bad file privileges. Consequently, VSC couldn’t access latexmk, which explains the error messages.

In my case, the problem occurred on a mac, and specifically after I installed MacTex, which, in turn, installs Tex Live. I believe the same solution may apply to linux distros too.


  1. Claim file ownership (which was originally root) under folder /usr/local/texlive: sudo chown -R <username> /usr/local/texlive, where <username> is the OS-level user name. The fix will work for this specific user. If it is not enough, try instead setting group owner appropriately, and/or consider Step 3.

  2. Add /usr/local/texlive/2021/bin/<software_dialect> to PATH. <software_dialect> depends on the installed software version: in my case it is universal-darwin; on linux it might be x86_64-linux.

  3. If the problem persists, try to change file access permissions under /usr/local/texlive using chmod.

EDIT: As a final step, restart VSC for changes to take effect.

Leave a Comment