Search code examples
visual-studio-codelatextex-livelatexmk

VSCode : latexmk is not found / can't compile tex documents (linux)


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.


Solution

  • 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 !