2

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?

12
  • works for me hello world Python 3.9.10 lualatex cygwin , though, not windows Jan 31, 2023 at 22:33
  • @DavidCarlisle yes it works fine for me too with wsl. Windows seems the culprit
    – mbert
    Jan 31, 2023 at 22:37
  • what does \makeatletter \ShellEscape{echo \@percentchar PATH\@percentchar } show is the directory with python in the path used by Lua ? Jan 31, 2023 at 22:39
  • "I have no idea what about lualatex, the Windows file system, or shellesc may be causing the issue. " It can't possibly be the last of these:-) Jan 31, 2023 at 22:42
  • @DavidCarlisle Good suggestion. It shows `C:\Users\mbert\AppData\Local\Programs\MiKTeX\miktex\bin\x64`, while pdflatex shows my full PATH
    – mbert
    Jan 31, 2023 at 23:15

1 Answer 1

1

I'm also stuck with the same problem on Windows 11 with MiKTex (after a fresh install of Windows).

I could reproduce everything that mbert wrote above: pdflatex/xelatex works, but in lualatex the PATH variable in \ShellEscape is wrongly set to contain only the directory of "lualatex.exe".

As suggested above by Ulrike Fischer, I checked lualatex.exe in the process monitor of Windows but couldn't find anything that would suggest that it is more restricted than pdflatex. I also turned off virus and threat protections under Windows, but it did not help.

The only work-around that currently works for me is to run (as suggested here) "latexmk -lualatex --enable-write18 FILENAME".

I made the following additional observations after a fresh install of Windows with MiKTex, TexStudio and TexMaker:

  • TexMaker: Surprisingly, lualatex worked for me for some time (in the sense that the PATH was correct in \ShellEscape), but after several computer restarts it stopped.
  • TexStudio, TexWorks, Powershell: It did not work right from the beginning.

So, at the same time when PATH worked in lualatex\ShellEscape for TexMaker, it failed for the others. I couldn't find out any relevant differences in the compilation settings of TexMaker/TexStudio. After some time, it stopped working for TexMaker, too. So I find this whole issue very strange.

As maybe others might find it helpful: I run into this whole issue with the Moodle package. When one wants to embed pictures in the produced output files, Moodle.sty is using \ShellEscape to run various commands from the PATH. And it fails for the reasons discussed above.

3
  • Thanks for the debugging and suggestions :-) I've given up and just switched to texlive where this issue isn't present (and as a bonus, texlive updates packages more frequently)
    – mbert
    Sep 15, 2023 at 15:27
  • Thank you very much for the suggestion. Now, I also switched to TexLive!
    – krfl
    Oct 6, 2023 at 16:09
  • This problem still persist, so I am switching from MiKTeX to TeXLive as suggested.
    – Mane32
    Dec 4, 2023 at 5:58

You must log in to answer this question.

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