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

YAML::Tiny module missing from MikTeX #374

Closed ChadBailey closed 2 years ago

ChadBailey commented 2 years ago

Please provide the following when posting an issue:

original .tex code

\documentclass{article}
\begin{document}
hello world
\end{document}

yaml settings

Please paste your YAML settings (if any) here

actual/given output

Error log:

[10:00:00] Formatting failed with exit code 2
[10:00:00] stderr: Can't locate YAML/Tiny.pm in @INC (you may need to install the YAML::Tiny module) (@INC contains: /[redacted]/AppData/Local/Programs/MiKTeX/scripts/latexindent [redacted]/AppData/Local/Programs/MiKTeX/scripts/latexindent/ /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl) at [redacted]/AppData/Local/Programs/MiKTeX/scripts/latexindent/LatexIndent/GetYamlSettings.pm line 22.

desired or expected output

No error

anything else

Reason I'm 100% new to Perl and LaTeX et all, so I'm surely doing something wrong. I also don't know if this is the fault of latexindent or MiKTeX, so my mistake if this is due to any of those things. I'm only posting to help the would-be newbie who doesn't have a software background.

Background/Setup I installed MiKTeX to manage my LaTeX + utilities, expecting it to be able to supply every package I need for a command line implementation. I'm using Visual Studio Code for editing LaTeX, with the LaTeX Workshop extension. I installed latexindent via the MiKTeX GUI. This works mostly, but I get the error shown above. It appears to not have the Yaml extension as a dependency but I'm unsure.

The exe file being referenced, even after removal of latexindent, is at %LOCALAPPDATA%\Programs\MiKTeX\miktex\bin\x64\latexindent.exe

When attempting to run latexindent from the command line it would reference the above file, prompting to reinstall the package resulting in a repeat pattern.

Small potentially unrelated environment note: I am using Cygwin

Resolution I manually removed %LOCALAPPDATA%\Programs\MiKTeX\miktex\bin\x64\latexindent.exe

Next I downloaded and extracted the .zip file from the latest release to a place folder in my %PATH%

This fully resolved the issue.

[10:22:31] Start formatting with latexindent.
[10:22:31] Format with command: latexindent
[10:22:31] Format with command args: ["-c","%DIR%/","%TMPFILE%","-y=defaultIndent: '%INDENT%'"]
[10:22:32] Formatted [redacted]\index.tex
cmhughes commented 2 years ago

Thanks for this.

Can you try the solution at https://tex.stackexchange.com/questions/577250/how-to-use-latexindent-on-windows

I've tried repeatedly to influence change on Miktex, but haven't been successful.

cmhughes commented 2 years ago

Oh, my mistake, I realise now that you've posted both a problem and a solution, thank you!

If ever you have ideas for improvements to the documentation, do feel free to submit a pull request :)

ChadBailey commented 2 years ago

No problem... sadly I am not fluent enough in MiKTeX, Perl, or LaTeX to really have any business attempting to resolve, but I would imagine the intended behavior is for this to work out of the box from MiKTeX.

If your package is broken in there, I would recommend either getting it fixed or delisting it. Having a broken package on the index doesn't do either side any favors. I wouldn't be quick to jump to that conclusion though, as I did not see anyone else post a similar issue anywhere.

For instance, perhaps this is a rare issue only invoked by a particular set of circumstances and this post along acts as ample documentation to the next poor person who runs into it. Hard to say.

I would recommend at minimum to figure out if the package needs YAML::Tiny to be declared as a dependency in the latexindent MiKTeX package, then get it declared if so,

If you do not maintain the latexindent MiKTeX package then I would recommend working with the person who is managing the package or request it be removed if you don't know who that is/how they are managing it.

An unknown package maintainer can be a huge security liability - they could one day slip a backdoor into the package without you knowing

At least, this is what I would say in other contexts. I have no idea how package management works with MiKTeX and Perl/LaTeX at large.

Hope that helps!

ChadBailey commented 2 years ago

Github automatically displays this, but in case you missed it I have posted a bug report to MiKTeX at https://github.com/MiKTeX/miktex/issues/1117

I hope this helps your voice be heard. I appreciate the hard work you've done on this tool, I think indentation and linting tools are under appreciated and critical to the workflow of people everywhere.