Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Can't locate File/HomeDir.pm in @INC

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?

like image 303
Yang Min Wang Avatar asked Oct 25 '13 12:10

Yang Min Wang


2 Answers

sudo perl -MCPAN -e 'install "File::HomeDir"'
                             ^             ^
like image 70
ikegami Avatar answered Nov 14 '22 02:11

ikegami


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

like image 30
Faisal Avatar answered Nov 14 '22 02:11

Faisal