In issue with minted and LuaLaTeX there is a discussion in the comments underneath the question and an answer confirming the issue. Since I can confirm the issue as well and have additional information to share, it seems better to continue the question than to extend the comments or provide a non-answer.
I used another MWE but one comparable to mbert's in the original question on two machines:
- Desktop CPU i9 32GB RAM Windows 11 V22H2 TeXStudio 4.4.1 MikTeX 2.9 updated Python 3.11 Pygments 2.14
- Laptop CPU AMD Athlon II 8GB RAM Xubuntu 22.04 TeXStudio 4.0.1 MikTeX 2.9 updated Python 3.11 Pygments 2.14
MWE used on both machines:
\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}{c}
int main() {
printf("hello, world");
return 0;
}
\end{minted}
\end{document}
I obtained the following results:
- Compiling with PDFLatex gave the desired result. The code in the
mintedenvironment was set properly. The additional directory created bymintedcontained two files: one with a long string name and one calleddefault.pygstyleof about 7kB. - Compiling with XeXeTeX provided an output in which all spaces and tabs were shown as
^^Iand the colouring of the code was absent. The^^Iis defined in thefancyvrbpackage. This occurred on both machines. - Compiling with LuaLaTeX was successful on the laptop (Xubuntu), but not on the desktop (Windows). The directory was created by
mintedunder Windows, but contained only the filedefault.pygstyleof 0kB. An empty one thus. - Compiling with PDFLaTeX followed by compiling with LuaLaTeX still gave the !Package minted Error: You must have
pygmentizeinstalled to use this package error, but did give a correct output. That second compiling used the directory created by the first one.
The difference in the logfile between the Xubuntu version and the Windows version is in:
runsystem(for ^%i in (pygmentize.exe pygmentize.bat pygmentize.cmd) do set > min
ted_test.aex <nul: /p x=^%~$PATH:i>> minted_test.aex)...failed
runsystem(del minted_test.aex)...executed
Under Windows the result of the shell escape comes back as failed, whereas under Xubuntu the result is executed. Both machines use the same shellesc:
Package: shellesc 2019/11/08 v1.0c unified shell escape interface for LaTeX
Package shellesc Info: Unrestricted shell escape enabled on input line 75.
To me it seems that there some kind of obscure issue in -shell-escape when using shellesc in LuaLaTeX on a Windows machine.
Hopefully someone more knowledgeable about the inner workings of shellesc on Windows command line can shed some light on this issue.
Note: Of course I can compile my .tex files on my laptop and drink a cup of coffee or more, but it would be nice to see the issue on my desktop solved.
Additional information Following instructions in the comments of the original question I found the following issue in the path statement when compiling using LuaLaTeX under Windows:
When I use the line \ShellEscape{path > path.txt} in PDFLaTeX I get a complete path statement in path.txt - as it should be. However when I use LuaLaTeX path.txt contains only one line: PATH=C:\Open Source\MikTeX\miktex\bin\x64\ which obviously isn't correct. So LuaLaTeX somehow purges the correct Windows path statement and replaces it with the MikTeX location.
\documentclass[11pt]{article}
\usepackage{shellesc}
\begin{document}
\ShellEscape{path > path.txt}
\end{document}
The MikTeX documentation on LuaLaTeX contains the following lines in the Options section:
When the LuaTeX executable starts, it looks for the --lua commandline option. If there is no --lua option, the commandline is interpreted in a similar fashion as in traditional pdfTeX. But if the option is present, LuaTeX will enter an alternative mode of commandline parsing in comparison to the standard MiKTeX programs. The presence of --lua makes most of other options unreliable, because the Lua initialization file can disable path searching and/or hook functions into various callbacks.
In my TeXStudio setup, there is no switch --lua present in the LuaLaTeX command. It just reads:
lualatex.exe -synctex=1 -interaction=nonstopmode --shell-escape %.tex
mintedmanual and on the website of python to install both python and pygments. There are spaces in both path environments, but no non-ascii characters. As PDFLatex compiling is successful, I wouldn't think those spaces should be a problem. – alchemist Jan 28 '23 at 17:56.styfiles in the minted map calledminted.sty(48kB) andminted1.sty(10kB). Both files contain a section that starts with\newcommand\TestAppExists[1]followed by\ifwindows(line 180 resp. 65). In that section there is a\ShellEscape{ .... }that calls on testing#1.exe #1.bat #1.com. In the followingelsesection\ShellEscape{ .... }only contains a call to#1. Guess that section is used on Apple and Linux installations. – alchemist Jan 29 '23 at 12:32