Debian 10下VSCode LaTeX Workshop报错spawn latexmk ENOENT,如何查找TeX Live二进制文件正确路径?
Hey there, let’s work through this frustrating issue you’ve been stuck on for 3 days. The core problem here is that your Flatpak-installed VS Code (we can tell from the .var/app/com.visualstudio.code-oss paths in your log) can’t find the latexmk executable you installed via apt. Let’s break this down step by step:
Step 1: Find the actual path of your TeX Live tools
Since you installed TeX Live and latexmk using apt (not the manual TeX Live download from the official site), their files aren’t in /usr/local/texlive—they’re in Debian’s default system directories. Run these commands to locate them:
To find exactly where
latexmkis installed:which latexmkFor more detailed output, you can also use:
dpkg -L latexmk | grep binNormally, apt-installed
latexmklives in/usr/bin/latexmk, but let’s confirm that.Verify the path of other TeX tools (like
pdflatex) to be sure:which pdflatexThis should also point to
/usr/binif your apt installation worked correctly.
Step 2: Fix Flatpak VS Code’s sandbox access
Flatpak apps run in a sandbox that limits access to system files by default. Even if latexmk is in /usr/bin, VS Code’s sandbox might not be able to see it. Here are two ways to fix this:
Option 1: Grant VS Code access to the system bin directory
Open your terminal and run this command to let your Flatpak VS Code access /usr/bin (where your TeX tools live):
flatpak override com.visualstudio.code-oss --filesystem=/usr/bin
Restart VS Code after running this, then try compiling your .tex file again.
Option 2: Manually specify latexmk’s path in LaTeX Workshop settings
If the sandbox override doesn’t work, you can directly tell LaTeX Workshop where to find latexmk:
- Open VS Code and press
Ctrl + ,to open the Settings panel - Search for LaTeX Workshop > Tools > Latexmk: Path
- Paste the full path you found in Step 1 (e.g.,
/usr/bin/latexmk) into this field - Save the settings, then restart VS Code and test your compile
Step 3: Double-check environment variables (if needed)
If you still run into issues, you can manually add the TeX tools path to VS Code’s environment variables:
- In VS Code Settings, search for LaTeX Workshop > Environment
- Add a new entry with the key
PATHand value/usr/bin:$PATH(replace/usr/binwith the path you found if it’s different) - Save and restart VS Code to apply the changes
内容的提问来源于stack exchange,提问作者Renegade_Coder




