添加条目 .bib 文件会破坏 VS Code 中的 LaTeX Workshop

添加条目 .bib 文件会破坏 VS Code 中的 LaTeX Workshop

当我向 .bib 文件添加条目并保存它时,编译时出现以下错误:

格式化失败。请参阅 LaTeX Workshop 输出了解详情。

按照提示,我在“输出”窗格的“LaTeX Workshop”选项卡中看到:

[10:55:52] LaTeX build process spawned. PID: 24624.
[10:55:52] Formatting with command latexindent -c,{folderName}/,{folderName}/__latexindent_temp.tex,-y=defaultIndent: '  '
[10:55:52] Parsed 151 bib entries from {folderName}/bibfile.bib.
[10:55:52] Formatting failed with exit code 2
[10:55:52] stderr: Can't locate File/HomeDir.pm in @INC (you may need to install the File::HomeDir module) (@INC contains: /usr/local/texlive/2017/texmf-dist/scripts/latexindent /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.4/darwin-thread-multi-2level /Library/Perl/Updates/5.18.4 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .) at /usr/local/texlive/2017/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm line 22.
BEGIN failed--compilation aborted at /usr/local/texlive/2017/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm line 22.
Compilation failed in require at /usr/local/texlive/2017/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm line 19.
BEGIN failed--compilation aborted at /usr/local/texlive/2017/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm line 19.
Compilation failed in require at /usr/local/texlive/2017/texmf-dist/scripts/latexindent/LatexIndent/Document.pm line 25.
BEGIN failed--compilation aborted at /usr/local/texlive/2017/texmf-dist/scripts/latexindent/LatexIndent/Document.pm line 25.
Compilation failed in require at /Library/TeX/texbin/latexindent line 27.
BEGIN failed--compilation aborted at /Library/TeX/texbin/latexindent line 27.

[10:55:52] Recipe of length 1 finished. PID: 24624.

我已经在(根据和)安装了cpan和。我尝试安装但无法安装。不过,这个错误消息令人困惑,因为错误perl/usr/bin/which perlwhich cpanFile::HomeDir未被抛出如果我在此会话中没有修改 bibfile.bib。例如,如果我保存 bibfile 并重新启动 VS Code,问题就会“消失”。

答案1

解决方案如下:

latexindent:无法在@INC 中找到 Log/Log4perl.pm(您可能需要安装 Log::Log4perl 模块)

这篇文章最初对我不起作用的原因是我使用的是 Mac 的默认版本和perl5.18 cpan,并且这些版本安装在一个不容易访问的文件夹中cpan。在我运行brew install perl安装了 5.30 的之后/usr/local/bin,我能够按照上述链接中所述解决问题。

相关内容