cmhughes / latexindent.pl

Perl script to add indentation (leading horizontal space) to LaTeX files. It can modify line breaks before, during and after code blocks; it can perform text wrapping and paragraph line break removal. It can also perform string-based and regex-based substitutions/replacements. The script is customisable through its YAML interface.
GNU General Public License v3.0
884 stars 84 forks source link

Can't locate File/HomeDir.pm in @INC #338

Closed Nbelles closed 2 years ago

Nbelles commented 2 years ago

Please provide the following when posting an issue:

I'm having some issues trying to run perl latexindent.pl from the terminal. In some cases it runs just fine and other times it gives the error as shown below. I say "times" but what I really mean is that in one window of my terminal I am able to run the file just fine but when in the same working directory but from another terminal tab it gives me the output below. I've spent a very long time trying to reinstall the File::HomeDir module but it keeps saying it is already installed. I started down the path of trying to get it to run because it was giving me an error when in VSCode running the TEX Workshop extension but I have yet to get it working there. I've searched all over the web and people keep saying to try and install other packages but none of them seem to install properly. Thanks for any advice you can give.

original .tex code

N/A

yaml settings

N/A

actual/given output

Can't locate File/HomeDir.pm in @INC (you may need to install the File::HomeDir module) (@INC contains: /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent /Library/Perl/5.30/darwin-thread-multi-2level /Library/Perl/5.30 /Network/Library/Perl/5.30/darwin-thread-multi-2level /Network/Library/Perl/5.30 /Library/Perl/Updates/5.30.3/darwin-thread-multi-2level /Library/Perl/Updates/5.30.3 /System/Library/Perl/5.30/darwin-thread-multi-2level /System/Library/Perl/5.30 /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level /System/Library/Perl/Extras/5.30) at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm line 23.
BEGIN failed--compilation aborted at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm line 23.
Compilation failed in require at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm line 21.
BEGIN failed--compilation aborted at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm line 21.
Compilation failed in require at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/Replacement.pm line 20.
BEGIN failed--compilation aborted at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/Replacement.pm line 20.
Compilation failed in require at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/Document.pm line 27.
BEGIN failed--compilation aborted at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/Document.pm line 27.
Compilation failed in require at latexindent.pl line 27.
BEGIN failed--compilation aborted at latexindent.pl line 27.

desired or expected output

N/A

anything else

N/A

cmhughes commented 2 years ago

Thanks for this.

Can you let me know which operating system you're on, and which perl version you have?

cmhughes commented 2 years ago

From your output, I'm guessing you might be on Linux.

Here is a link to how I install and use perlbrew on my Ubuntu machine:

https://latexindentpl.readthedocs.io/en/latest/sec-appendices.html#perlbrew

Nbelles commented 2 years ago

I'm using macOS 12.2 (non-M1 if that matters). The perl version according to the command perl --version is v5.34.0 for Darwin-thread-multi-2level.

Nbelles commented 2 years ago

I had to restart my computer for other reasons and when the terminal instances re-opened, they just worked. Not sure what fixed it but I'm guessing there is just some versioning issue somewhere on my computer but I'm not currently experiencing it. I am still having issues with getting latexindent to run within VSCode but I'll open up a separate issue for that because I think that is unrelated.

cmhughes commented 2 years ago

Try

      cpanm YAML::Tiny
      cpanm File::HomeDir
      cpanm Unicode::GCString

See .github/workflows/batch-check.yaml for demonstration of how this is installed on a mac in github actions.