UPDATE - Solution found

With thanks to Alan I was able to resolve the issue. My two problems were.

  1. I didn't know how to set the correct paths in LaTeX Workshop on VSCode
  2. I hadn't corrrectly run the perl installation command from the tex-live installation page

Just a note to anyone struggling with the installation, when you get to the part with the perl script on this page. It will take at least 20 minutes - 40 minutes to download the necessary dependencies. I thought I had done something wrong, but in the end it all works now!

A big thanks to Alan for his help.

Original Issue

I'm new to this site and while I have read previous posts that are similar, I'm still unclear about the process. I'd appreciate it if you could hold off from judgement, until you've read the post.

I read this article which produces the unsuccessful result I'm getting. There are clues in it, but nothing crystal clear.

I'm new to Ubuntu and I'm trying to make sense of a lot of new processes... I would like to view .tex files in VSCodes LaTeX Workshop.

I'm able to see that I have 40 associated packages with latexmk which I found through the apt-file search latexmk.

usr/share/texlive exists and there are 174530 packages associated with it. I've downloaded LaTeX Workshop on to my VSCode instance.

I'm not sure which executables need to be presented in the path as there are so many packages although I do know how to to update the path. I also know that there are paths in the LaTeX Workshop setting configuration. Most of which I can set with usr/bin/latexmk or similar.

I'm really not sure what I'm missing. I've included a log of the error that I'm getting when I try to run Build LaTeX Project/

[15:33:39.209][Extension] $SHELL: /bin/bash
[15:33:39.210][Extension] $LANG: C.UTF-8
[15:33:39.210][Extension] $LC_ALL: undefined
[15:33:39.210][Extension] process.platform: linux
[15:33:39.210][Extension] process.arch: x64
[15:33:39.210][Extension] vscode.env.appName: Visual Studio Code
[15:33:39.210][Extension] vscode.env.remoteName: wsl
[15:33:39.210][Extension] vscode.env.uiKind: 1
[15:33:39.211][Extension] LaTeX Workshop initialized.
[15:33:39.214][Format][Bib] Bibtex format config: {"tab":"  ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[15:33:39.217][Extension] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"]
[15:33:39.220][Manager] Current workspace folders: ["file://%WS1%"]
[15:33:39.221][Manager] Found root file from active editor: %WS1%/demo_1.tex
[15:33:39.222][Manager] Root file changed: from undefined to %WS1%/demo_1.tex
[15:33:39.222][Manager] Start to find all dependencies.
[15:33:39.222][Manager] Root file languageId: latex
[15:33:39.223][Event] ROOT_FILE_CHANGED: "%WS1%/demo_1.tex"
[15:33:39.223][Cacher][Watcher] Reset.
[15:33:39.228][Cacher] Adding %WS1%/demo_1.tex .
[15:33:39.228][Cacher][Watcher] Watched %WS1%/demo_1.tex with a new watcher on %WS1% .
[15:33:39.229][Event] FILE_WATCHED: "%WS1%/demo_1.tex"
[15:33:39.231][Cacher] Caching %WS1%/demo_1.tex .
[15:33:39.232][Cacher] Updated inputs of %WS1%/demo_1.tex .
[15:33:39.232][Cacher] Parse LaTeX AST: %WS1%/demo_1.tex .
[15:33:39.232][Event] ROOT_FILE_SEARCHED
[15:33:39.236][Server] valdOrigin is
[15:33:39.245][Cacher] Parsed LaTeX AST: %WS1%/demo_1.tex .
[15:33:39.245][Cacher][Path] Calling usr/bin/kpsewhich to resolve article.cls .
[15:33:39.252][Cacher] Updated elements in 6.96 ms: %WS1%/demo_1.tex .
[15:33:39.252][Event] FILE_PARSED: "%WS1%/demo_1.tex"
[15:33:39.255][Cacher][Path] Non-existent .fls for %WS1%/demo_1.tex .
[15:33:39.256][Structure] Structure force updated with 0 root sections for %WS1%/demo_1.tex .
[15:33:39.256][Event] STRUCTURE_UPDATED
[15:33:44.449][Commander] BUILD command invoked.
[15:33:44.449][Commander] The document of the active editor: file://%WS1%/demo_1.tex
[15:33:44.449][Commander] The languageId of the document: latex
[15:33:44.449][Manager] Current workspace folders: ["file://%WS1%"]
[15:33:44.450][Manager] Found root file from active editor: %WS1%/demo_1.tex
[15:33:44.450][Manager] Keep using the same root file: %WS1%/demo_1.tex
[15:33:44.450][Structure] Structure updated with 0 root sections for %WS1%/demo_1.tex .
[15:33:44.450][Event] ROOT_FILE_SEARCHED
[15:33:44.451][Event] STRUCTURE_UPDATED
[15:33:44.451][Commander] Building root file: %WS1%/demo_1.tex
[15:33:44.451][Builder] Build root file %WS1%/demo_1.tex
[15:33:44.455][Builder] outDir: %WS1% .
[15:33:44.458][Builder] Preparing to run recipe: latexmk.
[15:33:44.458][Builder] Prepared 1 tools.
[15:33:44.463][Builder] Recipe step 1 The command is latexmk:["-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=%WS1%","%WS1%/demo_1"].
[15:33:44.463][Builder] env: {}
[15:33:44.464][Builder] root: %WS1%/demo_1.tex
[15:33:44.464][Builder] cwd: %WS1%
[15:33:44.739][Builder] LaTeX build process spawned with PID undefined.
[15:33:44.740][Builder] LaTeX fatal error on PID undefined. Error: spawn latexmk ENOENT
[15:33:44.740]Error: spawn latexmk ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

1 Answer 1


You need to add the PATH to the "env": key of the LaTeX tools in the settings.

To do this:

Command-Shift-P -> Preferences Open User Settings (JSON)

Search for latex-workshop.latex.tools

Inside this array of objects are each of the build tools. When you first install they look (roughly) like this:

        "name": "latexmk",
        "command": "latexmk",
        "args": [
        "env": {}

You can see that there is an empty "env": attribute. This is what you need to change for all of the tools. So instead of having "env": {} you should replace it with the following. You first need to know what the path is for the TeX Live binaries after you install. To do this you can type in the command line:

which pdflatex

This will return the full path for pdflatex. On my machine, (a Mac) it returns:


So I would add the following to the "env": attributes:

"env": {"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:"}

For a Linux distribution like yours, the path will be somewhat different, perhaps something like:


and this is what you should use in your "env": attributes:

"env": {"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/texlive/2023/bin/x86_64-linux/:"}

You should add this for all the objects in the tools array (including the arara tool, which doesn't have an "env": attribute, but should).

You don't need to do anything with the recipes array.

Save the settings file and things should work as you expect.

  • Thank you Alan. I don't think my tex-live installation worked properly on first try. After going through the process again (tug.org/texlive/quickinstall.html) I've just triggered the perl script installations. Is it meant to take so long? I've 4562 packages that are being installed and it's going to take around half an hour to get it all installed. Is this normal? I will do what you suggested straight after this installation has completed. Thanks for your really helpful response.
    – Lauro235
    Jul 18, 2023 at 16:08
  • Just download the MacTeX installer instead. Much easier, then run TeX Live Utility to update the distribution to the latest versions.
    – Alan Munn
    Jul 18, 2023 at 16:30
  • Good point, but because I'm on WSL, I'm not sure that would work?
    – Lauro235
    Jul 18, 2023 at 16:33
  • 1
    Oh sorry, I totally misread your question. The path I gave you is one that will work for the Mac, but not Linux. So instead of /Library/TeX/texbin you should add the path that gets returned when you type which pdflatex from the command line, once your installation is complete.
    – Alan Munn
    Jul 18, 2023 at 16:49
  • 1
    I've updated the answer with both Mac and Linux details.
    – Alan Munn
    Jul 18, 2023 at 17:54

You must log in to answer this question.

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