This question stems from my question here about minted and lualatex, with similar issues reported by another user here.
I think I've isolated the issue to the following. minted relies on \ShellEscape from shellesc, which seems to fail in specific cases when compiling with lualatex, at least on Windows.
For example the following compiles as expected with pdflatex --shell-escape and xelatex --shell-escape.
\documentclass{article}
\usepackage{shellesc}
\begin{document}
\ShellEscape{mkdir myfolder}
\ShellEscape{echo hello world}
\ShellEscape{python --version} % this line is the problem
\end{document}
With lualatex --shell-escape, the commands mkdir and echo work as expected: a directory myfolder is created and hello world is printed in the terminal. But instead of printing Python 3.11.1 in the terminal like pdflatex and xelatex, compiling with lualatex prints
'python' is not recognized as an internal or external command,
operable program or batch file.
So for some reason lualatex with shell escape can't find the same programs installed on my computer as pdflatex and xelatex. For reference, I'm compiling with lualatex 1.16.0 from miktex on a machine with Windows 10. The document above works perfectly with a Linux machine and a slightly older lualatex, so my assumption is that Windows is part of the issue.
I have no idea what about lualatex, the Windows file system, or shellesc may be causing the issue. Any help is appreciated.
Edit
As David Carlisle helped determine in the comments, adding \ShellEscape{echo \@percentchar PATH\@percentchar } shows that lualatex only has access to the programs in C:\Users\mbert\AppData\Local\Programs\MiKTeX\miktex\bin\x64. Running the same with pdflatex or xelatex shows all the locations added to my PATH variable, including the one to python.
Why would this issue of a restricted PATH only arise with lualatex and not pdflatex or xelatex?
hello world Python 3.9.10lualatex cygwin , though, not windows – David Carlisle Jan 31 '23 at 22:33\makeatletter \ShellEscape{echo \@percentchar PATH\@percentchar }show is the directory with python in the path used by Lua ? – David Carlisle Jan 31 '23 at 22:39C:\Users\mbert\AppData\Local\Programs\MiKTeX\miktex\bin\x64\, while pdflatex shows my full PATH – mbert Jan 31 '23 at 23:15python.batin miktex bin that set the path back and called a real python – David Carlisle Feb 01 '23 at 00:13