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

Trying to use latexindent in VSCode #339

Closed Nbelles closed 2 years ago

Nbelles commented 2 years ago

Please provide the following when posting an issue:

I'm not sure exactly what the source of what might be causing this issue but I believe I have it setup in VSCode such that it runs latexindent on file save. It attempts to run latexindent but fails according to the LaTeX Workshop output (as seen in the output below). Walking through the pieces of the command, I do have latexindent installed at that location /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/latexindent.pl.

I tried opening a terminal on my computer and opening that directory and running the latexindent.pl using ./latexindent.pl it give the error: zsh: exec format error: latexindent even though running perl latexindent.pl works just fine Please enter text to be indented: (press CTRL+D when finished).

I have a feeling it is potentially wrong with my latexindent install because when I try running it from the terminal it gives me that error shown above, otherwise I would think that it might be something wrong with the LaTeX Workshop module of VSCode.

Thanks for any insight.

original .tex code

\documentclass{article}

\title{Test}
\author{Test 123}
\date{\today}

\begin{document}

\maketitle

\end{document}

yaml settings

N/A

actual/given output

From LaTeX Workshop output tab in VSCode: [19:23:48] Start formatting with latexindent. [19:23:48] Formatting with command /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/latexindent -c="/Users/Nathaniel/" "/Users/Nathaniel/__latexindent_temp.tex" -y=defaultIndent: ' ' [19:23:48] Formatting failed: spawn /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/latexindent EACCES [19:23:48] stderr: [19:23:48] Formatting failed with exit code -13 [19:23:48] stderr:

desired or expected output

N/A

anything else

N/A

cmhughes commented 2 years ago

Try the following commands from the terminal, stop when you get the first one that works:

latexindent latexindent.pl perl latexindent.pl

cmhughes commented 2 years ago

latexindent should be available from any directory, as it should be in your path. You shouldn't have to use the leading "./" as in

./latexindent.pl

Nbelles commented 2 years ago

Here is the output from running the following commands:

[computer:~]
[Nathaniel]% latexindent
zsh: exec format error: latexindent
[computer:~]
[Nathaniel]% latexindent.pl
zsh: command not found: latexindent.pl
[computer:~]
[Nathaniel]% perl latexindent.pl
Can't open perl script "latexindent.pl": No such file or directory
[computer:~]
[Nathaniel]% cd /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent/ 
[computer:latexindent]
[Nathaniel]% perl latexindent.pl
Please enter text to be indented: (press CTRL+D when finished)
[computer:latexindent]
[Nathaniel]% 
cmhughes commented 2 years ago

This looks like it's a problem with your path.

Is your texlive path in your PATH variable? The first option should work fine.

Nbelles commented 2 years ago

How would I check that?

cmhughes commented 2 years ago

On Linux I think the command is

echo $PATH

I think it's similar on Mac, https://stackoverflow.com/questions/14617041/how-can-i-see-the-current-value-of-my-path-variable-on-os-x#:~:text=You%20need%20to%20use%20the,contents%20as%20a%20command%20name .

On Sun, 13 Feb 2022, 20:06 Nathaniel.Belles, @.***> wrote:

How would I check that?

— Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/339#issuecomment-1038394537, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYHDMD3D4WASWWDLTZLU3AFM7ANCNFSM5OH2UWSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

Nbelles commented 2 years ago

Here's what my path looks like right now: /opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/Nathaniel/Library/Python/3.8/bin

cmhughes commented 2 years ago

I don't see the texlive path you posted previously in that path.

On Sun, 13 Feb 2022, 20:12 Nathaniel.Belles, @.***> wrote:

Here's what my path looks like right now: /opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/Nathaniel/Library/Python/3.8/bin

— Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/339#issuecomment-1038397839, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYA6TQ76PLKFX25YBDLU3AGC7ANCNFSM5OH2UWSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

Nbelles commented 2 years ago

Which path do I need to add to it? Just /usr/local/texlive or /usr/local/texlive/2021basic/texmf-dist/scripts or /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent?

cmhughes commented 2 years ago

Does your pdflatex work from the terminal...? What steps do you normally follow to get your texlive working?

On Sun, 13 Feb 2022, 20:19 Nathaniel.Belles, @.***> wrote:

Which path do I need to add to it? Just /usr/local/texlive or /usr/local/texlive/2021basic/texmf-dist/scripts or /usr/local/texlive/2021basic/texmf-dist/scripts/latexindent?

— Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/339#issuecomment-1038401675, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYCIBKVJAEFHD2KYUQDU3AG3LANCNFSM5OH2UWSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

Nbelles commented 2 years ago

Yes, running pdflatex test.tex (the same test.tex file as before) works just fine.

cmhughes commented 2 years ago

Can you add usr/local/texlive/2021basic/texmf-dist/scripts to your path?

cmhughes commented 2 years ago

I'm closing this, let me know if it isn't resolved.

Nbelles commented 2 years ago

Sorry I wasn't able to get back to this until just now.

I've added that directory to my path and I get the error zsh: permission denied: latexindent

Nbelles commented 2 years ago

I just tried doing a which latexindent to see if my terminal knows where it exists and it returns latexindent not found

Nbelles commented 2 years ago

@cmhughes Just tagging you in case you didn't see the notifications because this is closed.

cmhughes commented 2 years ago

I'm afraid I don't have much to add to what I've said already in this thread already.

The problem appears to be one centered on your path variable. You need to get your path variable set up so that includes the directory that latexindent is installed in.

This varies from operating system to operating system. For example, on Linux I can edit my bashrc file.

It's not clear to me if every user of your operating system has the same issue. I would hope not and hope that I would have heard from others prior to now.

In summary : you need to find a way to update your path variable to include the directory latexindent is installed in.

On Wed, 23 Feb 2022, 19:51 Nathaniel.Belles, @.***> wrote:

@cmhughes https://github.com/cmhughes Just tagging you in case you didn't see the notifications because this is closed.

— Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/339#issuecomment-1049154378, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYFVQFEISLL37PWWI23U4U3FLANCNFSM5OH2UWSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

cmhughes commented 2 years ago

Which user does latexindent.pl belong to? Maybe it has been installed as root and needs to have its permissions changed?