I have installed TexLive on Ubuntu 20.04.1 LTS using

sudo apt-get install texlive

After this I created a file "text.tex" in Visual Studio Code. I installed the Plugin "Latex Workshop" and tried to preview or Build the .tex File.

I received the following error:

Recipe terminated with fatal error: spawn latexmk ENOENT.

According to this:


The reason for this is, that something is wrong with the PATH Variable

I am not sure whether TexLive is actually included in my PATH:

Using echo $PATH yields:


I can use latex-v and which latex yields:


TexLive itself is located at:


I have tried to debug this by following the advice from the github page - I copied the content of m PATH variable into the "env" fields in the settings.json of LatexWorkshop, however, the error persists.

Someone solved a fairly similar problem here: How can I get VS Code LaTeX Workshop to choose the correct Latex distribution? This was on Windows however.

I am not sure whether something is wrong with my TexLive installation, my PATH variable or something is buggy or falsely set up within VSCode/LatexWorkshop.

  • 2
    Have you checked that you actually have latexmk? Ubuntu breaks texlive up into a number of Ubuntu packages (not to be confused with latex packages). You can use the apt-file tool to figure out which Ubuntu package provides latexmk (apt-file search latexmk), I think it is called latexmk. Note that apt-file needs sudo apt-file update from time to time.
    – daleif
    Jan 25, 2021 at 14:47
  • @daleif That was just it. Just reinstalled it using sudo apt-get install latexmk. Now everything works as intented. TY!
    – MrTony
    Jan 25, 2021 at 15:19

2 Answers 2


On Ubuntu TeXLive is split into many Ubuntu packages (not related to LaTeX packages). Some of the software tools that come with TeXLive are also split into their own Ubuntu packages. And since installing the Ubuntu texlive package does not install everything TeXLive relatated, chances are that you are missing something.

In this case the Ubuntu package latexmk provides the latexmk tool.

I looked it up via apt-file search latexmk. Note that other Ubuntu packages match as well but that is mostly latexmkrc configuration files.

Note if you use the apt-file tool, remember to run sudo apt-file update from time to time. This updates the file lists that apt-file search searches.


One way to fix this issue (MacOS):

Step1: reinstall maxtax 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.