9

Observation

When I press Ctrl+S in a sample.tex I get the following error: LaTeX fatal error: spawn latexmk ENOENT, . PID: undefined.. It seems to be a path related error. I assume this occurs because the Latex Workshop extension tries to compile something.

Debugging

I like the syntax highlighting, and I expect there may be some other functionalities in the LaTex Workshop extension that I can appreciate in the near future. However, I don't want it to do anything other than save the file I edited when I press Ctrl+s. I assume it does not need some advanced path to do that, as it knows where the file is located, since it was opened from some location. When I press Ctrl+F inside the extension settings and type: compile, I get 8 results of which I found the Latex-workshop>Latex>Recipes and Latex-workshop>latex:Tools to be containing the word compile. However I did not yet find an option to disable compilation when saving.

To verify the error is caused by the LaTex Workshop extension, I disabled it, tried saving the edited sample.tex file using Ctrl+s. That worked perfectly fine without raising errors.

Note, the mentioned error can be resolved with: sudo apt install latexmk as explained in this answer. However, I would prefer VScode not to start compiling when I save a file.

Question

How can I ensure VScode saves an edited .tex file when I press Ctrl+s, without throwing errors, whilst using the LaTex Workshop extension?

2 Answers 2

15

I also began writing LaTeX in VScode recently, and had the same problem.

If you make your way over to the settings UI in VScode and scroll down, you will find an option that you can change to prevent VScode from autobuilding. You can change this input to "onSave" achieving your goal.

setting

1
  • 2
    Awesome! Thank you for including the image, that made it even easier to find!
    – a.t.
    Commented Feb 3, 2022 at 0:42
6

You can also navigate to

File -> Preferences -> Settings -> Open Settings (JSON) (top right)

and add the following to your settings.json file:

"latex-workshop.latex.autoBuild.run": "never",

This achieves the same as the accepted answer but is an alternative way. More information can be found in the GitHub documentation about options for autoBuild.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .