I have Strawberry Perl and MiKTeX v2.9 installed on Windows 10 with the latexindent package installed via the MiKTeX console.

However, running latexindent.pl in the command prompt results in the following error

Can't locate Log/Log4perl.pm in @INC (you may need to install the Log::Log4perl module) (@INC contains: C:/Program Files/MiKTeX 2.9/scripts/latexindent C:/Strawberry/perl/site/lib C:/Strawberry/perl/vendor/lib C:/Strawberry/perl/lib) at C:/Program Files/MiKTeX 2.9/scripts/latexindent/LatexIndent/LogFile.pm line 22. BEGIN failed--compilation aborted at C:/Program Files/MiKTeX 2.9/scripts/latexindent/LatexIndent/LogFile.pm line 22. Compilation failed in require at C:/Program Files/MiKTeX 2.9/scripts/latexindent/LatexIndent/Document.pm line 25. BEGIN failed--compilation aborted at C:/Program Files/MiKTeX 2.9/scripts/latexindent/LatexIndent/Document.pm line 25. Compilation failed in require at C:\Program Files\MiKTeX 2.9\scripts\latexindent\latexindent.pl line 27. BEGIN failed--compilation aborted at C:\Program Files\MiKTeX 2.9\scripts\latexindent\latexindent.pl line 27.

Additionally, this answer doesn't help in removing the error. So, what is missing here?

  • 3
    Your Perl distribution is missing a module that's required by latexindent. The simplest way of installing a Perl module is using cpan. See What's the easiest way to install a missing Perl module? and Installing modules using Strawberry Perl on StackOverflow. – Nicola Talbot Aug 10 at 16:01
  • 1
    for Windows users, there is also latexindent.exe which doesn't need a perl installation. available from ctan ctan.org/pkg/latexindent – cmhughes Aug 17 at 16:53
  • 1
    to anyone reading this: I'd really like help in trying to communicate how to install perl modules and/or latexindent. the vast majority of questions on this site revolve around installation, which means that I clearly need to do more work in helping. please feel free to help me with this at http://github.com/cmhughes/latexindent.pl/ – cmhughes Aug 17 at 17:00
up vote 4 down vote accepted

Thanks to @Nicola's comment, the error can be fixed as follows:

  1. The missing module is Log::Log4perl as found in the first line of the error.
  2. Open Win 10 start menu and search for CPAN client, then open it and run install Log::Log4perl. However, it may fail due to the common bug, which needs the installtion to be forced by running force install Log::Log4perl (from the CPAN client) or the other command prompt commands given by the answers to this question. In other words, for instance, the command cpan -f -i Log::Log4perl must be run from the command prompt NOT the CPAN client.
  3. Another module might be missing whose name can be identified as similarly done in the first step and installed the same way.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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