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

3

19

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?

Roye answered 25/10, 2013 at 12:35 Comment(0)
E
21
sudo perl -MCPAN -e 'install "File::HomeDir"'
                             ^             ^
Eggcup answered 25/10, 2013 at 14:1 Comment(5)
or just sudo cpan -i File::HomeDirNonalignment
or just sudo cpan File::HomeDirRammish
It gives following error: HASCOMPILERbM3C/TESTkh3J.c:2:10: fatal error: 'EXTERN.h' file not foundSlotter
@alper, Ask as a question.Eggcup
@Eggcup I am sorry I will ask as a question. It's related to Apple's introduced System Integrity Protection. Please see: https://mcmap.net/q/610818/-quot-fatal-error-39-extern-h-39-file-not-found-quot-while-installing-perl-modulesSlotter
E
13

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

Elson answered 28/3, 2022 at 3:21 Comment(1)
The -i is implied when there are no other switches, so you could simply have cpan Unicode::GCString.Ejaculation
E
9

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.

Enzymolysis answered 4/6, 2023 at 11:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.