2

When I add an entry to my .bib file and save it, I get an error on compilation that reads:

Formatting failed. Please refer to LaTeX Workshop Output for details.

Chasing the hint, I see in the LaTeX Workshop tab of the OUTPUT pane:

[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.

I have cpan and perl installed in /usr/bin/ (according to which perl and which cpan). I tried installing File::HomeDir but was not able to do so. Still, this error message is confusing, because the error is not thrown if I have not modified bibfile.bib this session. For example, the problem "goes away" if I save the bibfile, and restart VS Code.

1

The solution was contained in here:

latexindent: Can't locate Log/Log4perl.pm in @INC (you may need to install the Log::Log4perl module)

The reason why this post didn't initially work for me is that I was using Mac's default version of perl and cpan, 5.18, and that these are installed in a folder that isn't easily accessible to cpan. After I ran brew install perl, which installed 5.30 in /usr/local/bin, I was able to solve the problem as described in the above link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.