Recipe terminated with fatal error: spawn latexmk ENOENT
Asked Answered
M

14

47

I have just installed debian 10 as well as vscode. I have been struggling with this for 3 days now.. I installed texlive from terminal with the following command:

sudo apt install texlive

I then installed the latex workshop extension in vscode and tried building a .tex file. The following error popped up:

Recipe terminated with fatal error: spawn latexmk ENOENT.

I then preceded to install latexmk from terminal with:

sudo apt install latexmk

The same error kept popping up after that. The output showed this.

[14:59:34] Recipe step env: {}
[14:59:34] cwd: /home/phoenix/Documents/stellies/year4/2021/s&s-414/pracs/prac-4/report
[14:59:34] LaTeX build process spawned. PID: undefined.
[14:59:35] LaTeX fatal error: spawn latexmk ENOENT, . PID: undefined.
[14:59:35] Does the executable exist? PATH: /app/bin:/usr/bin:/home/phoenix/.var/app/com.visualstudio.code-oss/data/node/bin:/home/phoenix/.var/app/com.visualstudio.code-oss/data/cargo/bin:/home/phoenix/.var/app/com.visualstudio.code-oss/data/python/bin
[14:59:35] The environment variable $SHELL: /bin/sh

I then proceded to review the texlive website. I noticed that i did not set the path variable to include the texlive binaries. The texlive website gives the following path to the binary files : PATH=/usr/local/texlive/2021/bin/x86_64-linux:$PATH however /usr/local/texlive does not exist on my system for some reason. Where can i find the correct path to the texlive binaries on Debian 10?

Myrilla answered 29/6, 2021 at 13:7 Comment(2)
only vaguely related: I would not use the debian package but install vanilla texlive directly from the TUG homepage. This way you are more flexible with your updates and don't have to deal with the confusing debian packaging of latex packages.Withdrawn
sounds related to github.com/James-Yu/LaTeX-Workshop/issues/1742Withdrawn
T
38

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.

Solution:

  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.

Thermoelectric answered 30/9, 2021 at 17:43 Comment(5)
Thanks, worked like a charm! I used this answer to add path to my zsh :)Preliminaries
How do you check if the problem is from bad file privileges? I'm having this issue in MacOs, with latex in my PATH, but LatexWorkshop does not seem to be grabbing PATH correctly (created issue #74537847).Frymire
This didn't work for me. I also had to do some extra steps, ie killing the vscode processes on remote and removing the .vscode-server folder. Here is the step-by-step guide: https://mcmap.net/q/372483/-visualstudiocode-with-latexworkshop-gives-spawn-latexmk-enoent-but-latex-is-in-the-path-macos (an answer to @Frymire question)Chokebore
For Arch Linux users: This error is caused by a reorganization of the texlive packages. See my answer below on how to fix it.Bach
Under Ubuntu 22.04.3, the TexLive path was /usr/share/texlive/Anglin
B
18

If you run into this error on Arch Linux: The Tex Live package has been re-organized a few days ago (June 18th, 2023) as this note shows.

This might cause some annoying behaviour because some commands that were part of previous packages might have been transferred into packages that you first need to install before you can use those commands again. Furthermore, one is not notified about this upon system update.

latexmk is an example of this. This thread here documents that it has been transferred to the texlive-binextra package. Install it via

pacman -S texlive-binextra

and VSCODE will find latexmk again...

Bach answered 27/6, 2023 at 13:11 Comment(0)
E
14

I recently encountered the same problem on MacOS Monterrey (M1 based). I used basictex (just for the context). As required by the installation instruction,

  1. I added TeXLive to PATH,
  2. installed latexmk package to the TeX distribution.

However, still got the same error as OP.

Afte reading the wiki again more carefully, what finally worked for me was as simple as restarting VS Code and MacOS. Everything works as expected after a reboot of the MAC.

Engage answered 16/11, 2021 at 5:39 Comment(5)
Thanks, I tried that, got that error out of the way, but now Im getting another error, it says recipe terminated with errorBash
rebooting VScode works. ThanksAngelicangelica
Rebooting VS Code worked by itself for me. But the preview didn't work. I had to manually build it using the TeX toolbar on the left-panel. After that, preview works with dynamic updates.Orva
If recipe terminated error happens after reloading the window, try "clean auxiliary files" from ctrl+shift+P and build again.Sukiyaki
Worked for me too. Important to note maybe: A simple restart of VS Code did not work, as well as reloading the window did not work. Only quitting VS Code and rebooting the MAC, as you described, helped.Lyndialyndon
C
4

I had a similar problem. I needed to install some extra packages on Linux.

sudo apt install texlive-extra-utils
sudo apt install latexmk
sudo apt-get install -y texlive-science

And then restart VSCode.

Cora answered 15/7, 2023 at 0:51 Comment(0)
A
3

Had a similar error and came across this post when looking for a solution. I wanted to use texlive on Vscode with WSL2 on Windows 10. Installing texlive-full in wsl fixed this error for me.

Aftersensation answered 29/10, 2022 at 19:46 Comment(1)
This solved my problem as well on WSL1 (Windows).Cartoon
S
2

On Mac, this is a way to fix the issue

Step1: reinstall mactex by downloading it from this link: http://www.tug.org/mactex/mactex-download.html

Step2: In your terminal do cd /usr/local, you should see texlive folder

Step3: In your terminal do sudo vim etc/paths to set the environment. Details are in this link: https://www.architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion/

Step4: In your terminal do /usr/local/texlive/2021/bin/x86_64-linux at the bottom. check the folder to see if the year is correct. Details in: http://www.tug.org/texlive/quickinstall.html.

Step5: Quit VC code completely, and reopen it.

Stouthearted answered 11/9, 2021 at 14:32 Comment(1)
I did brew install --cask mactex and issue got resolvedHerbst
B
2

I had this same problem on Mac recently, the fix that worked for me was to uninstall and reinstall the LaTeX Workshop extension.

Backpedal answered 26/9, 2021 at 3:6 Comment(1)
Didn't work for me (on mac).Thermoelectric
G
2

I got the same issue , seems to be a misbehaving from Vscode on MacOS

  • check if the command is in the path on mac

-which command_you are running example which latexmk

If this output something that means you have your latex installed, otherwise go and installed it and make sure it is accessible via command line.

  • If latex is installed and you are getting that issue you can just restart your VSCode and everything will be okay.
Grubb answered 19/1, 2022 at 21:32 Comment(0)
I
1

Faced a similar problem, and the situation is funny:

-> latex crashes with error can't find latexmk

-> which latexmk says /usr/bin/latexmk

Error text ->

 Does the executable exist? $PATH: ... :/usr/bin: ...

The secret is that I installed VSCode via Gnome Applications, which installed it via flatpak (in its own container) and therefore it doesn't care about all environment variables, all settings and so on - it has its own atmosphere.

Cured by reinstalling vscode from the official site directly without flatpak

Indigestion answered 25/5 at 9:52 Comment(0)
M
0

The error message "Recipe terminated with fatal error: spawn latexmk ENOENT" suggests that the latexmk command cannot be found in the system path.

To resolve this issue, you can add the path to latexmk to your system environment variables:

Open the Start menu and search for "Environment Variables". Click on "Edit the system environment variables". Click on the "Environment Variables" button. Under "System Variables", scroll down and find the "Path" variable. Click on "Edit" and then "New". Enter the path to the directory where latexmk is installed (e.g. C:\Program Files\MiKTeX 2.9\miktex\bin) and click "OK". Restart Visual Studio Code and try compiling your LaTeX document again. If latexmk is not installed on your system, you can install it using a LaTeX distribution such as MiKTeX or TeX Live. Once installed, the path to latexmk should be automatically added to your system environment variables.

If the issue persists, you can try specifying the full path to latexmk in your LaTeX Workshop settings by adding the following line to your settings.json file:

"latex-workshop.latex.tools": [
{
    "name": "latexmk",
    "command": "C:/Program Files/MiKTeX 2.9/miktex/bin/latexmk.exe",
    "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "-pdf",
        "%DOC%"
    ],
    "env": {}
}

]

Make sure to update the path to latexmk to match the location where it is installed on your system.

Musso answered 17/3, 2023 at 15:27 Comment(0)
S
0

When everything seems to be set fine, but it still doesn't work well. Please remember to set the default terminal for VScode, and then reboot your computer. The fix worked well with my MacOS.

command+shift+P : setting

open user setting

add

"terminal.integrated.defaultProfile.osx": "zsh",
"terminal.integrated.defaultProfile.windows": "PowerShell"

at the end of the file, just like the picture shown below:

enter image description here

Seacoast answered 28/5, 2023 at 8:12 Comment(0)
J
0

Similar to ychen's answer.

Since you have installed the texlive, you can check the path where the texlive is installed in texlive utility's preference, there should be an option to show you the path.

After that, you may try to "cd" to that path and "which latexmk" or "which pdftex" in the terminal (I used OS X) and check if it can return something.

Then you need to add this path to the environment variable of your OS by referring to "https://gist.github.com/nex3/c395b2f8fd4b02068be37c961301caa7". Sometimes you need to refresh the $PATH and make it done automatically.

Reopen the vscode and "latexkm" the tex files just in the built-in terminal and change some settings in "latex tools" of texshop extension.

These are what I have done to solve this problem.

Josefajosefina answered 4/11, 2023 at 11:59 Comment(0)
T
0

For those with TexLive installed on WSL2 and using Latex Workshop via VSCode Remote Development, note that the extension may mistakedly be searching for latexmk in your Windows $PATH instead of in the WSL path. To circumvent this, you can explicitly pass in a full path to your LaTeX command:

  1. Ctrl-F Latex: Tools in your Vs Code Settings. Click Edit in settings.json. In the first command value, paste the full path to latexmk, e.g.
"latex-workshop.latex.tools": [

       {
           "name": "latexmk",
           "command": "/usr/local/texlive/..your-path../latexmk",
           "args": [
               "-synctex=1",
               "-interaction=nonstopmode",
               "-file-line-error",
               "-pdf",
               "-outdir=%OUTDIR%",
               "%DOC%"
           ],
           "env": {}
       },
       ...
]
Tilburg answered 20/11, 2023 at 22:36 Comment(0)
B
0

Using Ubuntu + VSCode + Texlive (2019, 2021 or 2023) From the command line, my tex-v is working.

I had the same problem, you can try it by stopping all VSCode programs, then check the file naming and try opening it again. (This solved a lot of the problems I had)

I made this behavior upfront, which I think is also important

sudo visudo
add 
/usr/local/texlive/2023/bin/x86_64-linux
to PATH

Note the colon split.
Bradstreet answered 21/12, 2023 at 14:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.