Search code examples
visual-studio-codelatexvscode-extensionslog4perl

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


I'm using LaTeX Workshop on VSCode to build pdf using LaTeX and I'm getting this error in the Output console when I save the .tex file.

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.

The problem is only related to the formatting stuff because the build runs successfully generating the pdf as supposed.

What I did:

  • Opened the CPAN Client of my Windows 10
  • Run install Log::Log4perl (it installed also other packages like Log::Dispatch::File and YAML::Tiny)
  • Rebooted the system
  • Checked that Log4perl is installed and it is

I also tryied to install Log4perl through VSCode cmd but I'm getting this wierd error:

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

Any suggestions?


Solution

  • I figured it out in the end! To solve the error do:

    1. Download latexindent.exe
    2. Edit Latex-workshop › Latexindent: Path in the Latex Workshop VSCode extension settings with the latexindent.exe path