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?


4 Answers 4



Log4perl is definitely no longer required. See comments.

Original Answer

For others running into the same issue but on a Mac:

Install perl via brew:

brew install perl

Use cpan to install the necessary perl packages:

Open cpan and select yes if necessary to setup the config automatically:


Then install any packages mentioned in your error logs, you may need to install and retry several times to figure out all of the packages you need.

In my case these packages fixed the error messages:

install Log::Log4perl
install Log::Dispatch::File
install YAML::Tiny
install File::HomeDir

Catalina Update

If the installation fails with an error message that sounds like a permissions issue, that may be due to security changes in Catalina. In that case, try forcing the installation:

cpan -fi \
  Log::Log4perl \
  Log::Dispatch::File \
  YAML::Tiny \
  File::HomeDir \
  • 1
    The question is for OS W10.
    – Sebastiano
    Dec 22, 2019 at 19:06
  • 27
    People searching for the same issue on a Mac (per my case) also end up on this page.
    – songololo
    Dec 22, 2019 at 19:38
  • 6
    I also needed install Unicode::GCString Mac catalina and TeXLive 2019
    – Spangen
    Apr 19, 2020 at 9:29
  • 2
    @LaTeXereXeTaL brew is a separate package manager on the Mac. It is completely unrelated to Latex but allows you to install third-party packages (like perl in this case) that might be used by Latex. Google "homebrew" for installation instructions.
    – songololo
    Jul 22, 2020 at 10:26
  • 2
    I had to add sudo: sudo cpan -fi .... Feb 17, 2021 at 17:29

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.
  • 9
    For the record, on my Debian, the additional missing modules where Log::LogDispatch, Log::Dispatch::File, YAML::Tiny and File::HomeDir. You can install them all at once using cpan Log::LogDispatch Log::Dispatch::File YAML::Tiny File::HomeDir.
    – Clément
    Dec 23, 2018 at 2:19
  • 3
    For MacOS, this also included Unicode::GCString, so the full installation solution was: cpan -i Log::Log4perl Log::LogDispatch Log::Dispatch::File YAML::Tiny File::HomeDir Unicode::GCString. This should be packaged to run at the end of brew install mactex. Sep 5, 2019 at 20:27
  • @Clément cpan Log::Dispatch Log::Dispatch::File YAML::Tiny File::HomeDir
    – Bonjour123
    May 3, 2020 at 1:30
  • 1
    Too much installation just for indenting automatically
    – Emre
    Sep 21, 2020 at 13:46
  • 1
    @EmreSülün That is indeed a lot to install to indent automatically. On the other hand, indenting properly latex file is far from trivial (latexindent's documentation is over 100 pages!).
    – Clément
    Jan 24, 2021 at 17:33

As of Version 3.9 the Log4Perl module is no longer loaded by latexindent.pl.

Details of the required perl modules are documented and sample installations steps are given in .travis.yml and appveyor.yml

I sincerely hope that this eases installation and use of the tool. If you can help make latexindent.pl better, or have any questions, please visit https://github.com/cmhughes/latexindent.pl.


MacOS Big Sur

New problems arise for Big Sur. Here is my Fix.

(The solution assumed you've installed homebrew. )

Step 1. Install the perl & its package manager

brew install perl
brew install cpanm

Step 2. Create symlink for MacOSX10.14.sdk

Install the missing packages directly will raise the build error:

clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]

That's because:

Apple decided to stop naming their SDKs with versions but rather name them MacOSX.sdk and include an alias with the version name for compatibility

So we create symlink for this folder. (Difference between recent SDKs is minor)

> cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
> sudo ln -s MacOSX.sdk MacOSX10.14.sdk

Step 3. Install the missing packages

cpanm YAML::Tiny
cpanm File::HomeDir
cpanm Unicode::GCString
cpanm Log::Log4perl
cpanm Log::Dispatch
  • Log4Perl no longer required :)
    – cmhughes
    Aug 18, 2021 at 16:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .