VSCode:找不到 Latexmk/无法编译 tex 文档(linux)

问题描述 投票:0回答:1

我的发行版是 Zorin-OS 16.3(基于 ubuntu 20.04)并且是最新的。另外,我使用 VSCode 的 flatpak 版本。

我目前正在尝试使用 VSCode 来编译我的乳胶文档。我已经为 bin 下载了 TexLive,并为 VSCode 安装了扩展“Latex Workshop”。

我已经测试了我的 bin,我可以在 bash 中使用 Latexmk 手动编译 .tex 文档(下面是测试代码和输出)。

\documentclass{article}


\begin{document}

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

\end{document} 

但问题是,当我尝试使用“Latex Workshop”扩展进行编译时,出现了此错误:

Recipe terminated with fatal error: spawn latexmk ENOENT
。我在互联网上到处寻找此错误的解决方案,但似乎没有一个有效。所以我更深入地寻找问题,并尝试使用 Latexmk 在 VSCode 的内部终端中进行编译,但出现了此错误:

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

所以我尝试查看我的操作系统的正常 bash(仅通过 Ctrl+Alt+T 打开的 bash)是否确实存在 Latexmk 并输出以下内容:

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

所以现在我确定它在哪里了,我在 PATH 中查看了

/usr/local/texlive/2023/bin/x86_64-linux
是否在(确实如此),之后我尝试在 INSIDE VSCode 终端中执行相同的操作,但它输出了以下内容:

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)

正如您所看到的,信息完全矛盾,因为 TexLive bins 位于 PATH 中,如错误行所示...但 Latexmk 位于 TexLive bins 中,所以为什么它找不到它?

我没有任何具体的问题,任何想法都会帮助我,因为我完全迷失了,而且这样已经一个多星期了。

注意:使用完全相同的过程,VSCode 找不到 pdflatex,并且它输出完全相同的错误消息。我假设它会对每个 TexLive bin 执行相同的操作,因为 VSCode 由于某些不明原因找不到它们。

visual-studio-code latex tex-live latexmk
1个回答
0
投票

我不知道它对于寻找解决方案是否有用,但当我尝试编译 .tex 文档时,我更仔细地查看了日志,这是完整的输出:

[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

在所有这些日志中,引起我注意的是这一行:

[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

正如您所见,扩展“LateX Workshop”似乎没有使用我的正常路径(您可以在上面我的第一条消息中找到它)。

所以现在我认为唯一的问题(我希望)是“LateX Workshop”可以访问的路径,但现在我的问题是:为什么有不同的路径?我该如何改变它?

© www.soinside.com 2019 - 2024. All rights reserved.