1

I try to run latexindent under macOS (12.0.1) from Visual Studio Code (1.63.0) with the LaTeX Workshop plug-in (v8.22.0). It doesn't work because an error occurs during formatting.

I have already installed these cpan packages :

  • Log::Log4perl (1.54)
  • Log::Dispatch::File (2.70)
  • YAML::Tiny(1.73)
  • File::HomeDir (1.006)
  • Unicode::GCString (2013.10)
  • File::HomeDir (1.006)
  • Mac::SystemDirectory (0.13)

I also tried to update the CPATH environment variable with this command

export CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk/System/Library/Perl/5.34/darwin-thread-multi-2level/CORE:$CPATH

This also did not work.

The Perl executable is in this folder: /opt/homebrew/bin/perl. I have the version v5.34.0. I have already read this latexindent: trouble installing File::HomeDir, Mac::SystemDirectory since macOS 11 Big Sur.

Can someone give me some hints on how to solve this problem?

Here is the error output :

[23:14:18] Start formatting with latexindent.
[23:14:18] Formatting with command /Library/TeX/texbin/latexindent -c,/Users/daniel/Desktop/mwe/,/Users/daniel/Desktop/mwe/__latexindent_temp.tex,-y=defaultIndent: '    '
[23:14:18] Formatting failed with exit code 255
[23:14:18] stderr: Unknown PerlIO layer 'encoding' at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/Document.pm line 21.
Unknown PerlIO layer "encoding" at /opt/homebrew/Cellar/perl/5.34.0/lib/perl5/5.34.0/open.pm line 126.
Unknown PerlIO layer "encoding" at /opt/homebrew/Cellar/perl/5.34.0/lib/perl5/5.34.0/open.pm line 134.
Unknown PerlIO layer "encoding" at /opt/homebrew/Cellar/perl/5.34.0/lib/perl5/5.34.0/open.pm line 135.
Attempt to reload Encode.pm aborted.
Compilation failed in require at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm line 130.
BEGIN failed--compilation aborted at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm line 130.
Compilation failed in require at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm line 22.
BEGIN failed--compilation aborted at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm line 22.
Compilation failed in require at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/Lines.pm line 22.
BEGIN failed--compilation aborted at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/Lines.pm line 22.
Compilation failed in require at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/Document.pm line 28.
BEGIN failed--compilation aborted at /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/LatexIndent/Document.pm line 28.
Compilation failed in require at /Library/TeX/texbin/latexindent line 27.
BEGIN failed--compilation aborted at /Library/TeX/texbin/latexindent line 27.

[23:14:18] File watcher - file changed: /Users/daniel/Desktop/mwe/mwe.tex
[23:14:18] Parsing a file and its subfiles: /Users/daniel/Desktop/mwe/mwe.tex
[23:14:18] Checking for duplicate labels: /Users/daniel/Desktop/mwe/mwe.tex.
[23:14:18] Auto build started detecting the change of a file: /Users/daniel/Desktop/mwe/mwe.tex
[23:14:18] BUILD command invoked.
[23:14:18] The document of the active editor: file:///Users/daniel/Desktop/mwe/mwe.tex
[23:14:18] The languageId of the document: latex
[23:14:18] Building root file: /Users/daniel/Desktop/mwe/mwe.tex
[23:14:18] onDidSaveTextDocument triggered: file:///Users/daniel/Desktop/mwe/mwe.tex
[23:14:18] Build root file /Users/daniel/Desktop/mwe/mwe.tex
[23:14:18] outDir: /Users/daniel/Desktop/mwe
[23:14:18] Recipe step 1: lualatex, -lualatex,-shell-escape,-synctex=1,-interaction=nonstopmode,-file-line-error,/Users/daniel/Desktop/mwe/mwe
[23:14:18] Recipe step env: undefined
[23:14:18] cwd: /Users/daniel/Desktop/mwe
[23:14:18] LaTeX build process spawned. PID: 4557.
[23:14:18] LaTeX log parsed with 0 messages.
[23:14:18] A step in recipe finished. PID: 4557.
[23:14:18] Recipe step 2: biber, mwe
[23:14:18] Recipe step env: undefined
[23:14:18] cwd: /Users/daniel/Desktop/mwe
[23:14:18] LaTeX build process spawned. PID: undefined.
[23:14:18] LaTeX fatal error: spawn biber ENOENT, . PID: undefined.
[23:14:18] Does the executable exist? $PATH: /Users/daniel/perl5/bin:/Library/TeX/texbin/:/Applications/flutter/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Library/Apple/usr/bin
[23:14:18] Does the executable exist? $Path: undefined
[23:14:18] The environment variable $SHELL: /bin/zsh
Daniel Schreurs
  • 186
  • 1
  • 10
  • 1
    You seem to be missing a part of Perl itself?! – ikegami Dec 11 '21 at 23:38
  • What is the shebang line in the `latexindent` script? Try type `head -1 /Library/TeX/texbin/latexindent` – Håkon Hægland Dec 12 '21 at 09:34
  • This is the shebang line in the latexindent script : `#!/usr/bin/env perl` @HåkonHægland – Daniel Schreurs Dec 12 '21 at 10:39
  • @DanielSchreurs Ok, I am going to have a look at this. How did you install `latexindent`? Then I will start with tring to reproduce the error you got – Håkon Hægland Dec 15 '21 at 15:15
  • I installed _MacTeX_ with Homebrew through this command `brew install --cask mactex`. When I type the command `which latexindent` it gives this `/usr/local/texlive/2021/bin/universal-darwin/latexindent`. I have Perl v5.34.0 and it is here `/opt/homebrew/bin/perl`. @HåkonHægland I tried to _synthesize_ and mostly _isolate_ my problem [here](https://stackoverflow.com/questions/70341724/unable-to-run-latexindent-macos-monterey-12-0-1) with a new post. – Daniel Schreurs Dec 16 '21 at 19:50
  • Ok this seems to work for me on macOS 12.0.1, homebrew perl version 5.34.0. [Here](https://pastebin.com/QsESwJ3V) is what I did. As you can see, I needed to install some perl modules before I got `latexindent` working. – Håkon Hægland Dec 16 '21 at 23:54
  • Thank you @HåkonHægland for your answer ! I have just followed the procedure you suggest [here](https://pastebin.com/QsESwJ3V). But as you can see [here](https://pastebin.com/6kaKfzEi). As soon as I install _mactex_ with the command `brew install --cask mactex` it does not work anymore. The command `latexindent --help` does not suggest me _to install packages_ but gives me directly the _error_ `Unknown PerlIO layer 'encoding.....`. See code [here](https://pastebin.com/6kaKfzEi). – Daniel Schreurs Dec 17 '21 at 20:34
  • @DanielSchreurs Thanks for the update. Can you try to use the `encoding(utf-8)` IO layer directly with a one-liner? For example like this: `perl -Mutf8 -E 'use open ":std", ":encoding(utf-8)"; say ""'`. Do you get the same error? – Håkon Hægland Dec 17 '21 at 21:10
  • Thank you @HåkonHægland, Yes, I still have the same problem. It keeps saying that it doesn't know `PerlIO layer "encoding"`. [Here](https://pastebin.com/rs7GbHcP) is the output I get. – Daniel Schreurs Dec 17 '21 at 21:50
  • @DanielSchreurs Ok it might be some corrupt files. What version of perl are you using? Maybe the easiest would be to reinstall `perl` ? – Håkon Hægland Dec 17 '21 at 21:53
  • Does this answer your question? [Unable to run latexindent macOS Monterey 12.0.1](https://stackoverflow.com/questions/70341724/unable-to-run-latexindent-macos-monterey-12-0-1) – samcarter_is_at_topanswers.xyz Jul 07 '22 at 12:49

1 Answers1

0

This problem is related to the installation of latexindent under macOS. I have asked here a more specific question related to this problem and I give my solution.

Daniel Schreurs
  • 186
  • 1
  • 10