skip to Main Content

My distro is Zorin-OS 16.3 (which is based of ubuntu 20.04) and is up to date. Also, I use the flatpak version of VSCode.

I’m currently trying to use VSCode for compiling my latex documents. I have downloaded TexLive for the bins and I installed the extension "Latex Workshop" for VSCode.

I have already tested my bins and I can manually compile a .tex document with latexmk in the bash (Below, the test code and the output).

documentclass{article}


begin{document}

$sum_{n = 1}^{infty} wp ell$

end{document} 

test.tex pdf output

But the problem is that when i tried to compile with the "Latex Workshop" extension, this error appeared : Recipe terminated with fatal error: spawn latexmk ENOENT. I looked everywhere on the internet for a solution for this error but none seemed to work. So I looked deeper for the problem and tried to compile in the internal terminal of VSCode with latexmk but this error occured :

naim@GF65-Thin-10SDR:~/Bureau/PROGRAMMATION/LateX/TEST$ latexmk test.tex
bash: latexmk : command not found

So i tried to look on the NORMAL bash of my OS (the one opening just by doing Ctrl+Alt+T) if latexmk was really present and it outputed this :

naim@GF65-Thin-10SDR:~$ which latexmk
/usr/local/texlive/2023/bin/x86_64-linux/latexmk

So now that I know for sure where it is, I looked in the PATH if /usr/local/texlive/2023/bin/x86_64-linux was in (and indeed it was) and after that I tried to do the same thing in the terminal INSIDE VSCode but it outputed this :

naim@GF65-Thin-10SDR:~$ which latexmk
which: no latexmk in (/usr/local/texlive/2023/bin/x86_64-linux:/usr/local/texlive/2023/bin/x86_64-linux:/home/naim/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/app/bin:/app/bin:/app/bin:/usr/bin:/home/naim/.var/app/com.visualstudio.code/data/node_modules/bin)

As you can see the information LITTERALY contradict itself because the TexLive bins is in PATH as indicated in the error line…but latexmk is located in the TexLive bins so why it doesn’t find it ?

I don’t have any precise question, just any idea will help me because I’m totally lost and it has been like this for more than a week.

NOTE : With the exact same procedure, pdflatex is not found by VSCode and it outputs the exact same error messages. I assume that it will do the same for every TexLive bins because VSCode does not find them for some obscure reason.

2

Answers


  1. Chosen as BEST ANSWER

    I don't know if it will be useful for finding a solution but I've looked more closely at the logs when I try to compile my .tex document and here is the complete output :

    [02:24:46.517][Extension] onDidSaveTextDocument triggered: file://%WS1%/LateX/TEST/test.tex
    [02:24:46.584][Cacher][Watcher] "change" emitted on %WS1%/LateX/TEST/test.tex .
    [02:24:46.586][Cacher] Caching %WS1%/LateX/TEST/test.tex .
    [02:24:46.587][Cacher] Updated inputs of %WS1%/LateX/TEST/test.tex .
    [02:24:46.588][Cacher] Parse LaTeX AST: %WS1%/LateX/TEST/test.tex .
    [02:24:46.588][Builder] Auto build started detecting the change of a file: %WS1%/LateX/TEST/test.tex .
    [02:24:46.588][Event] AUTO_BUILD_INITIATED: {"type":"onChange","file":"%WS1%/LateX/TEST/test.tex"}
    [02:24:46.591][Commander] BUILD command invoked.
    [02:24:46.591][Commander] The document of the active editor: file://%WS1%/LateX/TEST/test.tex
    [02:24:46.591][Commander] The languageId of the document: latex
    [02:24:46.591][Commander] Building root file: %WS1%/LateX/TEST/test.tex
    [02:24:46.591][Builder] Build root file %WS1%/LateX/TEST/test.tex
    [02:24:46.592][Event] FILE_CHANGED: "%WS1%/LateX/TEST/test.tex"
    [02:24:46.594][Builder] outDir: %WS1%/LateX/TEST .
    [02:24:46.595][Builder] Preparing to run recipe: latexmk.
    [02:24:46.596][Builder] Prepared 1 tools.
    [02:24:46.597][Builder] Recipe step 1 The command is latexmk:["-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=%WS1%/LateX/TEST","%WS1%/LateX/TEST/test"].
    [02:24:46.597][Builder] env: {}
    [02:24:46.598][Builder] root: %WS1%/LateX/TEST/test.tex
    [02:24:46.598][Builder] cwd: %WS1%/LateX/TEST
    [02:24:46.605][Builder] LaTeX build process spawned with PID undefined.
    [02:24:46.607][Builder] LaTeX fatal error on PID undefined. Error: spawn latexmk ENOENT
    [02:24:46.607]Error: spawn latexmk ENOENT
        at ChildProcess._handle.onexit (node:internal/child_process:283:19)
        at onErrorNT (node:internal/child_process:476:16)
        at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    [02:24:46.608][Builder] Does the executable exist? $PATH: /app/bin:/app/bin:/app/bin:/usr/bin:/home/naim/.var/app/com.visualstudio.code/data/node_modules/bin, $Path: undefined, $SHELL: /bin/sh
    [02:24:46.608][Builder] 
    [02:24:46.610][Cacher] Parsed LaTeX AST: %WS1%/LateX/TEST/test.tex .
    [02:24:46.611][Cacher][Path] Calling kpsewhich to resolve article.cls .
    [02:24:46.620][Cacher] Updated elements in 9.29 ms: %WS1%/LateX/TEST/test.tex .
    [02:24:46.621][Event] FILE_PARSED: "%WS1%/LateX/TEST/test.tex"
    [02:24:46.622][Structure] Structure force updated with 0 root sections for %WS1%/LateX/TEST/test.tex .
    [02:24:46.623][Event] STRUCTURE_UPDATED
    

    In all those logs, the line that caught my attention is this one : [02:24:46.608][Builder] Does the executable exist?$PATH:/app/bin:/app/bin:/app/bin:/usr/bin:/home/naim/.var/app/com.visualstudio.code/data/node_modules/bin, $Path: undefined, $SHELL: /bin/sh

    As you may see, it seems like the extension "LateX Workshop" does NOT use my normal PATH (you can find it on my first message above).

    So now I think that the only problem (I hope) is the PATH that "LateX Workshop" can access but now my questions are : Why is there a different PATH ? How can I change it ?


  2. I HAVE FOUND THE SOLUTION !!

    With the help of my CS teacher, I understood that the /usr folder accessed by VSCode is not my normal /usr folder. More precisely it is located here : /var/lib/flatpak/runtime/org.freedesktop.Sdk/x86_64/22.08/62104f53f51a95dc4ac12aed498510e1b9bc30ed68c21543d6616f409519296d/files

    So I had to add the access to this folder and then I copy-pasted my texlive folder into it and it solved the issue !

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search