LaTeXindent 在 VSCode 中失败:找不到 Log/Log4perl.pm

LaTeXindent fail in VSCode: Can't locate Log/Log4perl.pm

我在 VSCode 上使用 LaTeX Workshop 使用 LaTeX 构建 pdf,但在保存 .tex 文件时我在输出控制台中收到此错误。

Formatting with command latexindent -c,d:path_to_folder,d:path_to_folder/__latexindent_temp.tex,-y=defaultIndent: ' '

Formatting failed with exit code 2

stderr: Can't locate Log/Log4perl.pm in @INC (you may need to install the Log::Log4perl module) (@INC contains: C:/Program Files/MiKTeX/scripts/latexindent C:/Perl64/site/lib C:/Perl64/lib) at C:/Program Files/MiKTeX/scripts/latexindent/LatexIndent/LogFile.pm line 22.

问题只与格式化有关,因为构建运行成功,生成了预期的 pdf。

我做了什么:

我也尝试通过 VSCode cmd 安装 Log4perl,但我收到了这个奇怪的错误:

Running make for E/ET/ETJ/Log-Log4perl-1.53.tar.gz
to undefined at C:/Perl64/site/lib/ExtUtils/Install.pm line 141.
make: *** [pm_to_blib] Error 255
  ETJ/Log-Log4perl-1.53.tar.gz
  "C:\Program Files (x86)\GnuWin32\bin\make.exe" -- NOT OK
Failed during this command:
 ETJ/Log-Log4perl-1.53.tar.gz                 : make NO

有什么建议吗?

我终于想通了!要解决错误,请执行:

  1. 下载latexindent.exe
  2. 编辑 Latex-workshop › Latexindent: Latex Workshop VSCode 扩展设置中的 Path latexindent.exe路径