2

I am learning with latexindent. I would like to follow up this question: How is automatic indentation done for subfiles with arara and latexindent? and ask for clarification:

Is there required any modification to arara rule indent.yaml or to configuration of latexindent? If I look on arara.yaml shipped with TeXlive 2019 on Windows 10, I see no support for option "files."

Code posted in linked question does not work for me with error exit code 1; indent.log says it cant find the file stated in "files" option...

As MWE may be used answer in linked question or this code:

Main.tex
% arara: indent: { overwrite: yes, files: [ main.tex, chapter/chapter.tex ] }
% arara: lualatex: { shell: yes }

\documentclass [a4paper, 12pt, twoside, openright] {book}
\usepackage{fontspec}

\usepackage{import}

\begin{document}

Main document test itemization.

\begin{itemize}
\item first item
\item second item
\item another item
\end{itemize}

\chapter{Imported chapter}

\import{chapter/}{chapter.tex}

\end{document}
/chapter/chapter.tex
Imported chapter itemization:

\begin{itemize}
\item first item
\item second item
\item another item
\end{itemize}

EDIT: Everything works, if I pot file "chapter.tex" into same folder as "Main.tex" and change arara indent rule accordingly. How can I specify search path to latexindent to find "chapter.tex" in different folder than "Main.tex" ?

EDIT 2: Modifyed MWE to get one run (the first one on file Main.tex, which is the one with arara directives) and posting content of indent.log created:

INFO: latexindent.exe version 3.7, 2019-07-13, a script to indent .tex files
      latexindent.exe lives here: C:/texlive/2019/bin/win32/
      Sat Sep 14 17:05:07 2019
      Filename: chapter.tex
INFO: Processing switches:
      -w|--overwrite: Overwrite mode active, will make a back up of chapter.tex first
INFO: Directory for backup files and indent.log: .
INFO: YAML settings read: defaultSettings.yaml
      Reading defaultSettings.yaml from C:/texlive/2019/bin/win32/defaultSettings.yaml
      Reading defaultSettings.yaml (2nd attempt, TeXLive, Windows) from C:/texlive/2019/bin/win32/../../texmf-dist/scripts/latexindent/defaultSettings.yaml
INFO: YAML settings read: indentconfig.yaml or .indentconfig.yaml
      Home directory is C:/Users/user (didn't find either indentconfig.yaml or .indentconfig.yaml)
      To specify user settings you would put indentconfig.yaml here: C:/Users/user/indentconfig.yaml
      Alternatively, you can use the hidden file .indentconfig.yaml as: C:/Users/user/.indentconfig.yaml
FATAL: I couldn't find chapter.tex, are you sure it exists?.
       No indentation done.
       Exiting.

EDIT: Contents of arara.log file as requested by Mr. Hughes: Ah, date is in my local setting. Hope it doesnt mind :)

15 Zář 2019 21:31:39.958 INFO  - Welcome to arara 4.0 (revision 1)!
15 Zář 2019 21:31:39.959 INFO  - -----------------------------------------------------------------
15 Zář 2019 21:31:39.961 INFO  - ::: arara @ C:\texlive\2019\texmf-dist\scripts\arara
15 Zář 2019 21:31:39.961 INFO  - ::: Java 1.8.0_221, Oracle Corporation
15 Zář 2019 21:31:39.961 INFO  - ::: C:\Program Files (x86)\Java\jre1.8.0_221
15 Zář 2019 21:31:39.961 INFO  - ::: Windows 10, x86, 10.0
15 Zář 2019 21:31:39.961 INFO  - ::: user.home @ C:\Users\Tomáš Kruliš
15 Zář 2019 21:31:39.961 INFO  - ::: user.dir @ D:\Dokumenty\Prace SUJB\Sujb migrace\Compilation arara speed test\TestLatexindent\MWE
15 Zář 2019 21:31:39.961 INFO  - ::: CF @ [none]
15 Zář 2019 21:31:39.962 INFO  - -----------------------------------------------------------------
15 Zář 2019 21:31:39.962 INFO  - Processing 'main.tex' (size: 451 bytes, last modified: 09/15/2019 21:29:57), please wait.
15 Zář 2019 21:31:39.968 INFO  - I found a potential pattern in line 1: indent: { overwrite: yes, files: [ main.tex, chapters/chapter.tex ] }
15 Zář 2019 21:31:39.968 INFO  - I found a potential pattern in line 2: lualatex: { shell: yes }
15 Zář 2019 21:31:40.004 INFO  - I found a potential directive: Directive: { identifier: indent, parameters: {overwrite=yes, files=[main.tex, chapters/chapter.tex]}, conditional: { NONE }, lines: [1] }
15 Zář 2019 21:31:40.005 INFO  - I found a potential directive: Directive: { identifier: lualatex, parameters: {shell=yes}, conditional: { NONE }, lines: [2] }
15 Zář 2019 21:31:40.006 INFO  - All directives were validated. We are good to go.
15 Zář 2019 21:31:40.006 INFO  - -------------------------- DIRECTIVES ---------------------------
15 Zář 2019 21:31:40.006 INFO  - Directive: { identifier: indent, parameters: {reference=D:\Dokumenty\Prace SUJB\Sujb migrace\Compilation arara speed test\TestLatexindent\MWE\Main.tex, file=Main.tex, overwrite=yes}, conditional: { NONE }, lines: [1] }
15 Zář 2019 21:31:40.006 INFO  - Directive: { identifier: indent, parameters: {reference=D:\Dokumenty\Prace SUJB\Sujb migrace\Compilation arara speed test\TestLatexindent\MWE\chapters\chapter.tex, file=chapter.tex, overwrite=yes}, conditional: { NONE }, lines: [1] }
15 Zář 2019 21:31:40.006 INFO  - Directive: { identifier: lualatex, parameters: {shell=yes, file=main.tex, reference=D:\Dokumenty\Prace SUJB\Sujb migrace\Compilation arara speed test\TestLatexindent\MWE\main.tex}, conditional: { NONE }, lines: [2] }
15 Zář 2019 21:31:40.006 INFO  - -----------------------------------------------------------------
15 Zář 2019 21:31:40.007 INFO  - I am ready to interpret rule 'indent'.
15 Zář 2019 21:31:40.008 INFO  - Rule location: 'C:\texlive\2019\texmf-dist\scripts\arara\rules'
15 Zář 2019 21:31:40.131 INFO  - I am ready to interpret task 'The latexindent.pl script' from rule 'Indent'.
15 Zář 2019 21:31:40.131 INFO  - System command: [ latexindent, -w, Main.tex ]
15 Zář 2019 21:31:40.851 INFO  - ---------------------- BEGIN OUTPUT BUFFER ----------------------
15 Zář 2019 21:31:40.851 INFO  - % arara: indent: { overwrite: yes, files: [ main.tex, chapters/chapter.tex ] }
% arara: lualatex: { shell: yes }

\documentclass [a4paper, 12pt, twoside, openright] {book}
\usepackage{fontspec}

\usepackage{import}

\begin{document}

Main document test itemization.

\begin{itemize}
    \item first item
    \item second item
    \item another item
\end{itemize}

\chapter{Imported chapter}

\import{chapter/}{chapter.tex}

\end{document}
15 Zář 2019 21:31:40.851 INFO  - ----------------------- END OUTPUT BUFFER -----------------------
15 Zář 2019 21:31:40.854 INFO  - Task result: SUCCESS
15 Zář 2019 21:31:40.855 INFO  - I am ready to interpret rule 'indent'.
15 Zář 2019 21:31:40.855 INFO  - Rule location: 'C:\texlive\2019\texmf-dist\scripts\arara\rules'
15 Zář 2019 21:31:40.860 INFO  - I am ready to interpret task 'The latexindent.pl script' from rule 'Indent'.
15 Zář 2019 21:31:40.861 INFO  - System command: [ latexindent, -w, chapter.tex ]
15 Zář 2019 21:31:41.548 INFO  - ---------------------- BEGIN OUTPUT BUFFER ----------------------
15 Zář 2019 21:31:41.548 INFO  - I couldn't find chapter.tex, are you sure it exists?.
No indentation done.
Exiting. at C:\Users\TOMKRU~1\AppData\Local\Temp\par-546f6de19a204b72756c699a\cache-e5261462a856ca06b13fe24504351eecc6e6a781\inc\lib/LatexIndent/FileExtension.pm line 88.

15 Zář 2019 21:31:41.548 INFO  - ----------------------- END OUTPUT BUFFER -----------------------
15 Zář 2019 21:31:41.549 INFO  - Task result: FAILURE
15 Zář 2019 21:31:41.551 INFO  - Total: 1.54 seconds

As requested by Mr. Cereda, I am adding arara.log file after using variant 1, using the "reference" arara key:

17 Zář 2019 14:26:38.494 INFO  - Welcome to arara 4.0 (revision 1)!
17 Zář 2019 14:26:38.494 INFO  - -----------------------------------------------------------------
17 Zář 2019 14:26:38.494 INFO  - ::: arara @ C:\Users\tomas.krulis\AppData\Local\Programs\MiKTeX 2.9\scripts\arara
17 Zář 2019 14:26:38.494 INFO  - ::: Java 1.8.0_221, Oracle Corporation
17 Zář 2019 14:26:38.494 INFO  - ::: C:\Program Files\Java\jre1.8.0_221
17 Zář 2019 14:26:38.494 INFO  - ::: Windows 7, x86, 6.1
17 Zář 2019 14:26:38.494 INFO  - ::: user.home @ C:\Users\tomas.krulis
17 Zář 2019 14:26:38.510 INFO  - ::: user.dir @ Z:\TestLatexindent\MWE
17 Zář 2019 14:26:38.510 INFO  - ::: CF @ [none]
17 Zář 2019 14:26:38.510 INFO  - -----------------------------------------------------------------
17 Zář 2019 14:26:38.510 INFO  - Processing 'Main.tex' (size: 501 bytes, last modified: 09/17/2019 14:26:25), please wait.
17 Zář 2019 14:26:38.510 INFO  - I found a potential pattern in line 1: indent: { overwrite: yes, reference: [ Z:\TestLatexindent\MWE\main.tex, Z:\TestLatexindent\MWE\chapters\chapter.tex ] }
17 Zář 2019 14:26:38.510 INFO  - I found a potential pattern in line 2: lualatex: { shell: yes }
17 Zář 2019 14:26:38.572 ERROR - There was a problem with the provided YAML map in a directive (1). This part is quite tricky, since it involves aspects of the underlying data serialization format. There are more details available on this exception:
17 Zář 2019 14:26:38.572 ERROR - while scanning a plain scalar
 in 'string', line 1, column 32:
    { overwrite: yes, reference: [ Z:\TestLatexindent\MWE\main.tex, ... 
                                   ^
found unexpected ':'
 in 'string', line 1, column 33:
    { overwrite: yes, reference: [ Z:\TestLatexindent\MWE\main.tex,  ... 
                                    ^
Please check http://pyyaml.org/wiki/YAMLColonInFlowContext for details.

17 Zář 2019 14:26:38.572 INFO  - Total: 0.00 seconds

It is tested on machine with MikTeX distribution (other machines I have access to have TeXlive 2019).

Looks straightforward.

But if I remove "Z:" with "." ; I am getting different error:

17 Zář 2019 14:32:45.364 INFO  - Welcome to arara 4.0 (revision 1)!
17 Zář 2019 14:32:45.364 INFO  - -----------------------------------------------------------------
17 Zář 2019 14:32:45.364 INFO  - ::: arara @ C:\Users\tomas.krulis\AppData\Local\Programs\MiKTeX 2.9\scripts\arara
17 Zář 2019 14:32:45.364 INFO  - ::: Java 1.8.0_221, Oracle Corporation
17 Zář 2019 14:32:45.364 INFO  - ::: C:\Program Files\Java\jre1.8.0_221
17 Zář 2019 14:32:45.364 INFO  - ::: Windows 7, x86, 6.1
17 Zář 2019 14:32:45.364 INFO  - ::: user.home @ C:\Users\tomas.krulis
17 Zář 2019 14:32:45.364 INFO  - ::: user.dir @ Z:\TestLatexindent\MWE
17 Zář 2019 14:32:45.364 INFO  - ::: CF @ [none]
17 Zář 2019 14:32:45.364 INFO  - -----------------------------------------------------------------
17 Zář 2019 14:32:45.379 INFO  - Processing 'Main.tex' (size: 499 bytes, last modified: 09/17/2019 14:32:31), please wait.
17 Zář 2019 14:32:45.379 INFO  - I found a potential pattern in line 1: indent: { overwrite: yes, reference: [ .\TestLatexindent\MWE\main.tex, .\TestLatexindent\MWE\chapters\chapter.tex ] }
17 Zář 2019 14:32:45.379 INFO  - I found a potential pattern in line 2: lualatex: { shell: yes }
17 Zář 2019 14:32:45.442 INFO  - I found a potential directive: Directive: { identifier: indent, parameters: {overwrite=yes, reference=[.\TestLatexindent\MWE\main.tex, .\TestLatexindent\MWE\chapters\chapter.tex]}, conditional: { NONE }, lines: [1] }
17 Zář 2019 14:32:45.442 INFO  - I found a potential directive: Directive: { identifier: lualatex, parameters: {shell=yes}, conditional: { NONE }, lines: [2] }
17 Zář 2019 14:32:45.442 ERROR - I read a directive (1) and found out that the key 'reference' was used. This key is reserved, so you cannot use it. But do not worry, this should be an easy fix. Just replace it by another name.
17 Zář 2019 14:32:45.442 INFO  - Total: 0.00 seconds

Which might be syntax problem? As far as I dont know, how to write absolute path in the "reference" field correctly? I am completely sure that all script and rule paths are correct, since I have all rules and TeX binaries in one place, and I have replaced the current rule with the one you suggested.

EDIT2: Using the solution #1 in answer provided by Mr. Cereda, with also arararc.yaml present in "main" project directory. I have redefined arara directives like so:

% arara: indent: { overwrite: yes, reference: [ Z:\TestLatexindent\MWE\main.tex, Z:\TestLatexindent\MWE\chapter\chapter.tex ] }
% arara: lualatex: { shell: yes }

Result is failed compilation with this arara.log content:

18 Zář 2019 08:51:06.724 INFO  - Welcome to arara 4.0 (revision 2)!
18 Zář 2019 08:51:06.724 INFO  - -----------------------------------------------------------------
18 Zář 2019 08:51:06.724 INFO  - ::: arara @ C:\Users\tomas.krulis\AppData\Local\Programs\MiKTeX 2.9\scripts\arara
18 Zář 2019 08:51:06.724 INFO  - ::: Java 1.8.0_221, Oracle Corporation
18 Zář 2019 08:51:06.724 INFO  - ::: C:\Program Files\Java\jre1.8.0_221
18 Zář 2019 08:51:06.724 INFO  - ::: Windows 7, x86, 6.1
18 Zář 2019 08:51:06.740 INFO  - ::: user.home @ C:\Users\tomas.krulis
18 Zář 2019 08:51:06.740 INFO  - ::: user.dir @ Z:\TestLatexindent\MWE
18 Zář 2019 08:51:06.740 INFO  - ::: CF @ Z:\TestLatexindent\MWE\arararc.yaml
18 Zář 2019 08:51:06.740 INFO  - -----------------------------------------------------------------
18 Zář 2019 08:51:06.740 INFO  - Processing 'main.tex' (size: 549 bytes, last modified: 09/18/2019 08:28:43), please wait.
18 Zář 2019 08:51:06.740 INFO  - I found a potential pattern in line 1: indent: { overwrite: yes, reference: [ Z:\TestLatexindent\MWE\main.tex, Z:\TestLatexindent\MWE\chapter\chapter.tex ] }
18 Zář 2019 08:51:06.740 INFO  - I found a potential pattern in line 2: lualatex: { shell: yes }
18 Zář 2019 08:51:06.756 ERROR - There was a problem with the provided YAML map in a directive (1). This part is quite tricky, since it involves aspects of the underlying data serialization format. There are more details available on this exception:
18 Zář 2019 08:51:06.756 ERROR - while scanning a plain scalar
 in 'string', line 1, column 32:
    { overwrite: yes, reference: [ Z:\TestLatexindent\MWE\main.tex, ... 
                                   ^
found unexpected ':'
 in 'string', line 1, column 33:
    { overwrite: yes, reference: [ Z:\TestLatexindent\MWE\main.tex,  ... 
                                    ^
Please check http://pyyaml.org/wiki/YAMLColonInFlowContext for details.

18 Zář 2019 08:51:06.756 INFO  - Total: 0.00 seconds

I guess this might be because I am writing the reference value in wrong syntax. If I omit the "Z:" in both reference "values," creating directives like this:

% arara: indent: { overwrite: yes, reference: [ \TestLatexindent\MWE\main.tex, \TestLatexindent\MWE\chapter\chapter.tex ] }
% arara: lualatex: { shell: yes }

I am getting failed compilation with this arara.log:

18 Zář 2019 09:24:21.417 INFO  - Welcome to arara 4.0 (revision 2)!
18 Zář 2019 09:24:21.433 INFO  - -----------------------------------------------------------------
18 Zář 2019 09:24:21.433 INFO  - ::: arara @ C:\Users\tomas.krulis\AppData\Local\Programs\MiKTeX 2.9\scripts\arara
18 Zář 2019 09:24:21.433 INFO  - ::: Java 1.8.0_221, Oracle Corporation
18 Zář 2019 09:24:21.433 INFO  - ::: C:\Program Files\Java\jre1.8.0_221
18 Zář 2019 09:24:21.433 INFO  - ::: Windows 7, x86, 6.1
18 Zář 2019 09:24:21.433 INFO  - ::: user.home @ C:\Users\tomas.krulis
18 Zář 2019 09:24:21.433 INFO  - ::: user.dir @ Z:\TestLatexindent\MWE
18 Zář 2019 09:24:21.433 INFO  - ::: CF @ Z:\TestLatexindent\MWE\arararc.yaml
18 Zář 2019 09:24:21.433 INFO  - -----------------------------------------------------------------
18 Zář 2019 09:24:21.433 INFO  - Processing 'Main.tex' (size: 545 bytes, last modified: 09/18/2019 09:23:57), please wait.
18 Zář 2019 09:24:21.448 INFO  - I found a potential pattern in line 1: indent: { overwrite: yes, reference: [ \TestLatexindent\MWE\main.tex, \TestLatexindent\MWE\chapter\chapter.tex ] }
18 Zář 2019 09:24:21.448 INFO  - I found a potential pattern in line 2: lualatex: { shell: yes }
18 Zář 2019 09:24:21.448 INFO  - I found a potential directive: Directive: { identifier: indent, parameters: {overwrite=yes, reference=[\TestLatexindent\MWE\main.tex, \TestLatexindent\MWE\chapter\chapter.tex]}, conditional: { NONE }, lines: [1] }
18 Zář 2019 09:24:21.448 INFO  - I found a potential directive: Directive: { identifier: lualatex, parameters: {shell=yes}, conditional: { NONE }, lines: [2] }
18 Zář 2019 09:24:21.448 ERROR - I read a directive (1) and found out that the key 'reference' was used. This key is reserved, so you cannot use it. But do not worry, this should be an easy fix. Just replace it by another name.
18 Zář 2019 09:24:21.448 INFO  - Total: 0.00 seconds

I am doing testing of suggested rules used to solve my issue by replacing the original one, indent.yaml, directly in arara scripts directory, so the updated indent.yaml should be picked up the same way as all other arara rules are.

For solution #2, with the new "directory" option, if I have understood GitHub conversation correctly, I am using such arara directives:

% arara: indent: { overwrite: yes }
% arara: indent: { overwrite: yes, directory: 'chapter', files: [ chapter.tex ] }
% arara: lualatex: { shell: yes }

I am getting also failed compilation with this arara.log:

18 Zář 2019 10:31:23.040 INFO  - Welcome to arara 4.0 (revision 2)!
18 Zář 2019 10:31:23.040 INFO  - -----------------------------------------------------------------
18 Zář 2019 10:31:23.040 INFO  - ::: arara @ C:\Users\tomas.krulis\AppData\Local\Programs\MiKTeX 2.9\scripts\arara
18 Zář 2019 10:31:23.040 INFO  - ::: Java 1.8.0_221, Oracle Corporation
18 Zář 2019 10:31:23.040 INFO  - ::: C:\Program Files\Java\jre1.8.0_221
18 Zář 2019 10:31:23.040 INFO  - ::: Windows 7, x86, 6.1
18 Zář 2019 10:31:23.055 INFO  - ::: user.home @ C:\Users\tomas.krulis
18 Zář 2019 10:31:23.055 INFO  - ::: user.dir @ Z:\TestLatexindent\MWE
18 Zář 2019 10:31:23.055 INFO  - ::: CF @ Z:\TestLatexindent\MWE\arararc.yaml
18 Zář 2019 10:31:23.055 INFO  - -----------------------------------------------------------------
18 Zář 2019 10:31:23.055 INFO  - Processing 'Main.tex' (size: 491 bytes, last modified: 09/18/2019 10:31:10), please wait.
18 Zář 2019 10:31:23.055 INFO  - I found a potential pattern in line 1: indent: { overwrite: yes }
18 Zář 2019 10:31:23.055 INFO  - I found a potential pattern in line 2: indent: { overwrite: yes, directory: 'chapter', files: [ chapter.tex ] }
18 Zář 2019 10:31:23.055 INFO  - I found a potential pattern in line 3: lualatex: { shell: yes }
18 Zář 2019 10:31:23.071 INFO  - I found a potential directive: Directive: { identifier: indent, parameters: {overwrite=yes}, conditional: { NONE }, lines: [1] }
18 Zář 2019 10:31:23.071 INFO  - I found a potential directive: Directive: { identifier: indent, parameters: {overwrite=yes, directory=chapter, files=[chapter.tex]}, conditional: { NONE }, lines: [2] }
18 Zář 2019 10:31:23.071 INFO  - I found a potential directive: Directive: { identifier: lualatex, parameters: {shell=yes}, conditional: { NONE }, lines: [3] }
18 Zář 2019 10:31:23.071 INFO  - All directives were validated. We are good to go.
18 Zář 2019 10:31:23.071 INFO  - -------------------------- DIRECTIVES ---------------------------
18 Zář 2019 10:31:23.071 INFO  - Directive: { identifier: indent, parameters: {overwrite=yes, file=Main.tex, reference=Z:\TestLatexindent\MWE\Main.tex}, conditional: { NONE }, lines: [1] }
18 Zář 2019 10:31:23.071 INFO  - Directive: { identifier: indent, parameters: {reference=Z:\TestLatexindent\MWE\chapter.tex, file=chapter.tex, overwrite=yes, directory=chapter}, conditional: { NONE }, lines: [2] }
18 Zář 2019 10:31:23.071 INFO  - Directive: { identifier: lualatex, parameters: {shell=yes, file=Main.tex, reference=Z:\TestLatexindent\MWE\Main.tex}, conditional: { NONE }, lines: [3] }
18 Zář 2019 10:31:23.071 INFO  - -----------------------------------------------------------------
18 Zář 2019 10:31:23.071 INFO  - I am ready to interpret rule 'indent'.
18 Zář 2019 10:31:23.071 INFO  - Rule location: 'C:\Users\tomas.krulis\AppData\Local\Programs\MiKTeX 2.9\scripts\arara\rules'
18 Zář 2019 10:31:23.211 INFO  - I am ready to interpret task 'The latexindent.pl script' from rule 'Indent'.
18 Zář 2019 10:31:23.211 INFO  - System command: [ latexindent, -w, Main.tex ]
18 Zář 2019 10:31:24.085 INFO  - ---------------------- BEGIN OUTPUT BUFFER ----------------------
18 Zář 2019 10:31:24.085 INFO  - % arara: indent: { overwrite: yes }
% arara: indent: { overwrite: yes, directory: 'chapter', files: [ chapter.tex ] }
% arara: lualatex: { shell: yes }

\documentclass [a4paper, 12pt, twoside, openright] {book}
\usepackage{fontspec}

\usepackage{import}

\begin{document}

Main document test itemization.

\begin{itemize}
    \item first item
    \item second item
    \item another item
\end{itemize}

\chapter{Imported chapter}

\import{chapter/}{chapter.tex}

\end{document}
18 Zář 2019 10:31:24.085 INFO  - ----------------------- END OUTPUT BUFFER -----------------------
18 Zář 2019 10:31:24.085 INFO  - Task result: SUCCESS
18 Zář 2019 10:31:24.085 INFO  - I am ready to interpret rule 'indent'.
18 Zář 2019 10:31:24.101 INFO  - Rule location: 'C:\Users\tomas.krulis\AppData\Local\Programs\MiKTeX 2.9\scripts\arara\rules'
18 Zář 2019 10:31:24.116 INFO  - I am ready to interpret task 'The latexindent.pl script' from rule 'Indent'.
18 Zář 2019 10:31:24.116 INFO  - System command: [ latexindent, -w, Z:\TestLatexindent\MWE\chapter.tex ] @ chapter
18 Zář 2019 10:31:24.927 INFO  - ---------------------- BEGIN OUTPUT BUFFER ----------------------
18 Zář 2019 10:31:24.927 INFO  - I couldn't find Z:\TestLatexindent\MWE\chapter.tex, are you sure it exists?.
No indentation done.
Exiting. at C:/Users/tomas.krulis/AppData/Local/Programs/MiKTeX 2.9/scripts/latexindent/LatexIndent/FileExtension.pm line 83.

18 Zář 2019 10:31:24.927 INFO  - ----------------------- END OUTPUT BUFFER -----------------------
18 Zář 2019 10:31:24.927 INFO  - Task result: FAILURE
18 Zář 2019 10:31:24.927 INFO  - Total: 1.85 seconds

I have updated arara to revision 2 just before, also updated to new rule suggested in solution #2. As far as my understanding goes, arara is searching for "chapter.tex" not in directory "chapter," but in main directory.

Edit3: As requested, location of "indent.yaml" is:

C:\Users\tomas.krulis\AppData\Local\Programs\MiKTeX 2.9\scripts\arara\rules

and content of "indent.yaml" dor solution #2 (new directory field) is as follows:

!config
identifier: indent
name: Indent
authors:
- Chris Hughes
- Paulo Cereda
commands:
- name: The latexindent.pl script
  command: >
    @{
        if (isEmpty(directory)) {
            return getCommand('latexindent', silent, trace, screenlog,
                   settings, cruft, overwrite, output, file,
                   modifylinebreaks, replacement, options, logfile);
        }
        else {
            return getCommandWithWorkingDirectory(directory,
                   'latexindent', silent, trace, screenlog,
                   settings, cruft, overwrite, output, reference,
                   modifylinebreaks, replacement, options, logfile);
        }
    }
arguments:
- identifier: silent
  flag: >
    @{
        isTrue(parameters.silent, '-s')
    }
- identifier: overwrite
  flag: >
    @{
        isTrue(parameters.overwrite, '-w')
    }
- identifier: trace
  flag: >
    @{
      if ([ 'default', 'complete' ].contains(parameters.trace)) {
          return isTrue(parameters.trace == 'default', '-t', '-tt');
      }
      else {
          throwError('You provided an invalid value for trace.');
      }
    }
- identifier: screenlog
  flag: >
    @{
        isTrue(parameters.screenlog, '-sl')
    }
- identifier: modifylinebreaks
  flag: >
    @{
        isTrue(parameters.modifylinebreaks, '-m')
    }
- identifier: settings
  flag: >
    @{
      check = parameters.containsKey('where');
      location = check ? parameters.where : '';
      if ([ 'local', 'onlydefault' ].contains(parameters.settings)) {
          return isTrue(parameters.settings == 'local', isTrue(check,
                 '-l='.concat(location), '-l'), '-d');
      }
      else {
          throwError('You provided an invalid value for settings.');
      }
    }
- identifier: cruft
  flag: >
    @{
        '-c='.concat(parameters.cruft)
    }
- identifier: logfile
  flag: >
    @{
        [ '-g', parameters.logfile ]
    }
- identifier: output
  flag: >
    @{
        [ '-o', parameters.output ]
    }
- identifier: where
  flag: >
    @{
      check = parameters.containsKey('settings');
      setting = check ? parameters.settings : '';
      if (setting != 'local') {
          throwError('This key requires a local setting.');
      }
    }
- identifier: replacement
  flag: >
    @{
      opts = [ 'full' : '-r', 'noverb' : '-rv', 'noindent' : '-rr' ];
      if (opts.keySet().contains(parameters.replacement)) {
          return opts[parameters.replacement];
      }
      else {
          throwError('You provided an invalid value for replacement.');
      }
    }

- identifier: options
  flag: >
    @{
        if (isList(parameters.options)) {
            return parameters.options;
        }
        else {
            throwError('I was expecting a list of options.');
        }
    }
- identifier: directory
  flag: >
    @{
        entry = toFile(parameters.directory);
        if (entry.isFile()) {
            throwError('I was expecting a directory.');
        }
        else {
            if (!isSubdirectory(entry)) {
                throwError('Only subdirectories are allowed.');
            }
            else {
                return entry;
            }
        }
    }

For configuration file (you mean arararc.yaml , yes?) in main folder I have used setup already mentioned:

!config
paths:
- '.'

Thinking that this might be the cause of error, I have changed arararc.yaml to point exactly into folder, in which before mentioned "indent.yaml" is placed, like so:

!config
paths:
- 'C:\Users\tomas.krulis\AppData\Local\Programs\MiKTeX 2.9\scripts\arara\rules'
6
  • Hello!could you post the contents of arara.log
    – cmhughes
    Sep 14, 2019 at 14:59
  • @cmhughes Hello Mr. Hughes! Do you mean indent.log? That is what I got. I modifyed MWE to get one succesfull run, the "Main.tex" file is the one with actual arara directives. I put indent.log text into question body. Sep 14, 2019 at 15:08
  • Hello! It'd be very helpful to see arara.log so that we can see what how it is calling latexindent :)
    – cmhughes
    Sep 14, 2019 at 15:23
  • @cmhughes OK, that would be very helpfull indeed. Can I ask you, where should this logfile be? Its not generated in the document current directory, and I am lso unable to find it in my entire computer file search... Sep 14, 2019 at 15:33
  • You might have to call arara with a particular switch...I can't remember it now, but check the manual, I think it's detailed there...m
    – cmhughes
    Sep 14, 2019 at 17:18

1 Answer 1

3

This behaviour might be seen like a bug, but it's actually expected. The file variable is normalized to hold only the file name, and any existing paths are stripped. The decision was taken because some TeX-related tools have problems when not being invoked in the same level of the provided file. As a means to address this, version 4.0 provides another variable named reference, which holds the full, canonical path of the provided file, from the root filesystem to the end point.

There are two approaches to make rules work, in this sense:

  1. The first approach is the most obvious, which involves replacing file by reference in the rule context. In the case of latexindent, the new rule would be like this:

    !config
    identifier: indent
    name: Indent
    authors:
    - Chris Hughes
    - Paulo Cereda
    commands:
    - name: The latexindent.pl script
      command: >
        @{
            return getCommand('latexindent', silent, trace, screenlog,
                   settings, cruft, overwrite, output, reference,
                   modifylinebreaks, replacement, options, logfile);
        }
    arguments:
    - identifier: silent
      flag: >
        @{
            isTrue(parameters.silent, '-s')
        }
    - identifier: overwrite
      flag: >
        @{
            isTrue(parameters.overwrite, '-w')
        }
    - identifier: trace
      flag: >
        @{
          if ([ 'default', 'complete' ].contains(parameters.trace)) {
              return isTrue(parameters.trace == 'default', '-t', '-tt');
          }
          else {
              throwError('You provided an invalid value for trace.');
          }
        }
    - identifier: screenlog
      flag: >
        @{
            isTrue(parameters.screenlog, '-sl')
        }
    - identifier: modifylinebreaks
      flag: >
        @{
            isTrue(parameters.modifylinebreaks, '-m')
        }
    - identifier: settings
      flag: >
        @{
          check = parameters.containsKey('where');
          location = check ? parameters.where : '';
          if ([ 'local', 'onlydefault' ].contains(parameters.settings)) {
              return isTrue(parameters.settings == 'local', isTrue(check,
                     '-l='.concat(location), '-l'), '-d');
          }
          else {
              throwError('You provided an invalid value for settings.');
          }
        }
    - identifier: cruft
      flag: >
        @{
            '-c='.concat(parameters.cruft)
        }
    - identifier: logfile
      flag: >
        @{
            [ '-g', parameters.logfile ]
        }
    - identifier: output
      flag: >
        @{
            [ '-o', parameters.output ]
        }
    - identifier: where
      flag: >
        @{
          check = parameters.containsKey('settings');
          setting = check ? parameters.settings : '';
          if (setting != 'local') {
              throwError('This key requires a local setting.');
          }
        }
    - identifier: replacement
      flag: >
        @{
          opts = [ 'full' : '-r', 'noverb' : '-rv', 'noindent' : '-rr' ];
          if (opts.keySet().contains(parameters.replacement)) {
              return opts[parameters.replacement];
          }
          else {
              throwError('You provided an invalid value for replacement.');
          }
        }
    
    - identifier: options
      flag: >
        @{
            if (isList(parameters.options)) {
                return parameters.options;
            }
            else {
                throwError('I was expecting a list of options.');
            }
        }
    
  2. The second approach involves adding an extra directory option in order to cover such cases. It's a bit more complicated, but we (the team) are actually considering it this approach in order to offer such support for all engines and other TeX-related tools. The reason for it is that we want to impose a certain restriction that arara can only process files under the main file hierarchy, as a means to mitigate abuse in the filesystem. In revision 2, we included a new helper method in order to achieve this support. A new rule would be:

    !config
    identifier: indent
    name: Indent
    authors:
    - Chris Hughes
    - Paulo Cereda
    commands:
    - name: The latexindent.pl script
      command: >
        @{
            if (isEmpty(directory)) {
                return getCommand('latexindent', silent, trace, screenlog,
                       settings, cruft, overwrite, output, file,
                       modifylinebreaks, replacement, options, logfile);
            }
            else {
                return getCommandWithWorkingDirectory(directory,
                       'latexindent', silent, trace, screenlog,
                       settings, cruft, overwrite, output, file,
                       modifylinebreaks, replacement, options, logfile);
            }
        }
    arguments:
    - identifier: silent
      flag: >
        @{
            isTrue(parameters.silent, '-s')
        }
    - identifier: overwrite
      flag: >
        @{
            isTrue(parameters.overwrite, '-w')
        }
    - identifier: trace
      flag: >
        @{
          if ([ 'default', 'complete' ].contains(parameters.trace)) {
              return isTrue(parameters.trace == 'default', '-t', '-tt');
          }
          else {
              throwError('You provided an invalid value for trace.');
          }
        }
    - identifier: screenlog
      flag: >
        @{
            isTrue(parameters.screenlog, '-sl')
        }
    - identifier: modifylinebreaks
      flag: >
        @{
            isTrue(parameters.modifylinebreaks, '-m')
        }
    - identifier: settings
      flag: >
        @{
          check = parameters.containsKey('where');
          location = check ? parameters.where : '';
          if ([ 'local', 'onlydefault' ].contains(parameters.settings)) {
              return isTrue(parameters.settings == 'local', isTrue(check,
                     '-l='.concat(location), '-l'), '-d');
          }
          else {
              throwError('You provided an invalid value for settings.');
          }
        }
    - identifier: cruft
      flag: >
        @{
            '-c='.concat(parameters.cruft)
        }
    - identifier: logfile
      flag: >
        @{
            [ '-g', parameters.logfile ]
        }
    - identifier: output
      flag: >
        @{
            [ '-o', parameters.output ]
        }
    - identifier: where
      flag: >
        @{
          check = parameters.containsKey('settings');
          setting = check ? parameters.settings : '';
          if (setting != 'local') {
              throwError('This key requires a local setting.');
          }
        }
    - identifier: replacement
      flag: >
        @{
          opts = [ 'full' : '-r', 'noverb' : '-rv', 'noindent' : '-rr' ];
          if (opts.keySet().contains(parameters.replacement)) {
              return opts[parameters.replacement];
          }
          else {
              throwError('You provided an invalid value for replacement.');
          }
        }
    
    - identifier: options
      flag: >
        @{
            if (isList(parameters.options)) {
                return parameters.options;
            }
            else {
                throwError('I was expecting a list of options.');
            }
        }
    - identifier: directory
      flag: >
        @{
            entry = toFile(parameters.directory);
            if (entry.isFile()) {
                throwError('I was expecting a directory.');
            }
            else {
                if (!isSubdirectory(entry)) {
                    throwError('Only subdirectories are allowed.');
                }
                else {
                    return entry;
                }
            }
        }
    

This is the open issue in which we are discussing the directory support. For us, it's pretty much settled, now we need to work on updating our rule pack (as well as the corresponding user manual entries) in order to reflect this.

By the way, as mentioned, the new helper method is only available from revision 2 on, so running it in older versions (even if it's in the 4.0 series), an error will be reported. Make sure to update arara to at least revision 2 using your TeX distro manager, so the aforementioned rule in approach #2 will have the expected behaviour. You can check the revision by looking at the header when running the tool: arara 4.0 (revision 2).

Note: as of September 16, 2019, revision 2 of arara 4.0 was successfully submitted to and processed by CTAN, so it will be available in a couple of hours in the CTAN mirrors.

17
  • Hello Mr. Cereda, thank you for your answer. I am humbled if I was part of reasoning why apply a general change in arara rules. If you allow, I wait for revision 2 to be available and then test it (I would guess that in 12 hours or so), and if I may, gladly accept your answer afterwards. The first solution you provided I am failing to make work, but since it (might) require specific way how to write the absolute path (if I simply copy it, I get errors, and if I try to change some parts of that, say, "\" to "/," I get them anyway :D), I wait to test the preffered solution. Sep 16, 2019 at 19:49
  • @TomášKruliš Hi! I believe the new version will be available soon. Meanwhile, I tried the first rule in my Linux box and it worked. Are you sure arara is using the correct indent.yaml file? Could you check arara.log in line 9 for the configuration file and (around) line 23 which contains the path for the rule location and see if they point to the correct files? Regarding paths, IIRC it should work either way (both slash and backslash) because the internal file representation usually normalizes them, but I must admit the lack of a proper Windows box makes debugging tricky. :) (>>>) Sep 16, 2019 at 21:03
  • (>>>) If needed, and if it's not too much trouble for you, maybe updating the question with the new arara.log after trying the new rules might help me understand what's going on. Every computer is a universe of its own. :) Sep 16, 2019 at 21:05
  • Updated the question with arara.log file content as requested. I am not sure if my issue could be troubleshooted from there, since I might be doing some basic mistake... Also, I would like to ask, how long can it take for revision 2 to be available to install? Right now I am using MikTeX (in few hours switching to TeXlive), but I still dont have access to any arara updates. Sep 17, 2019 at 12:40
  • @TomášKruliš thanks for the update! I got revision 2 already from TeX Live, maybe MiKTeX will update soon as well. Regarding your updated arara.log, since there's no configuration file found (as indicated by CF @ [none]), the tool is picking the default indent.yaml rule from your TeX distro and not the one coming from this answer. Remember to create a configuration file (e.g, arararc.yaml) and include the rule path pointing to your rule: check if this entry here helps: github.com/cereda/arara/issues/127#issuecomment-530310781 Sep 17, 2019 at 13:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .