17

I use a Mac OS X 10.8, and want to run the latexindent.pl perl script on my latex files. This script is made by https://github.com/cmhughes/latexindent.plx. When I run this script on a latexfile I get this error message:

Can't locate File/HomeDir.pm in @INC (@INC contains: /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.4/darwin-thread-multi-2level /Library/Perl/Updates/5.12.4 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12 .) at helloworld.pl line 10.
BEGIN failed--compilation aborted at helloworld.pl line 10.

It seems that I am missing the File::HomeDir module in perl so I tried to download it using:

sudo perl -MCPAN -e 'install File::HomeDir',

I get the following error:

Can't locate object method "install" via package "File::HomeDir".

I managed to install the YAML::Tiny package without any problems.

I tried to run:

1 #!/usr/bin/perl
2 
3 use strict;
4 use warnings;
5 use FindBin;
6 use YAML::Tiny;
7 use File::Copy;
8 use File::Basename;
9 use Getopt::Std;
10 use File::HomeDir;
11 
12 print "hello world";
13 exit;         

and got the same Error message as above...

Do anyone know what to do?

0

3 Answers 3

21
sudo perl -MCPAN -e 'install "File::HomeDir"'
                             ^             ^
5
  • 1
    or just sudo cpan -i File::HomeDir
    – friedo
    Oct 25, 2013 at 15:42
  • 4
    or just sudo cpan File::HomeDir Oct 25, 2013 at 21:59
  • 1
    It gives following error: HASCOMPILERbM3C/TESTkh3J.c:2:10: fatal error: 'EXTERN.h' file not found
    – alper
    Nov 25, 2019 at 16:07
  • @alper, Ask as a question.
    – ikegami
    Nov 25, 2019 at 16:09
  • @ikegami I am sorry I will ask as a question. It's related to Apple's introduced System Integrity Protection. Please see: stackoverflow.com/a/52997962/2402577
    – alper
    Nov 25, 2019 at 16:15
8

I had a similar problem. I just ran these commends, and it worked for me

sudo cpan -i File::HomeDir

then

sudo cpan -i Unicode::GCString

Basically, I will run latexindent file_name.tex, then an error message will appear that says you may need to install the XXXX module then I install the XXXX module using sudo cpan -i XXXX

1
  • 1
    The -i is implied when there are no other switches, so you could simply have cpan Unicode::GCString. Mar 28, 2022 at 11:57
1

I just had this problem with macOS M1. If you don't want to use sudo, which I would strongly recommend not to. You can install the formulae latexindent via brew:

brew install latexindent

This fixed my issue without having to use sudo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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