16

I've installed TeX Live 2016 as it was released today (thanks to the developers for that).

Now I have the following MWE:

\documentclass{article}
\usepackage{minted}
\begin{document}

\begin{minted}{ruby}
class Foo
  def init
    pi = Math::PI
    @var = "Pi is approx. #{pi}"
  end
end
\end{minted}

\end{document}

When running pdflatex --shell-escape test.tex it runs through the file and produces the PDF as expected. Doing the same with lualatex --shell-escape test.tex fails with

This is LuaTeX, Version 0.95.0 (TeX Live 2016) 
 system commands enabled.
(./test.tex
LaTeX2e <2016/03/31>
Babel <3.9r> and hyphenation patterns for 1 language(s) loaded.
(/opt/texlive/2016/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/opt/texlive/2016/texmf-dist/tex/latex/base/size10.clo))
(/opt/texlive/2016/texmf-dist/tex/latex/minted/minted.sty
(/opt/texlive/2016/texmf-dist/tex/latex/graphics/keyval.sty)
(/opt/texlive/2016/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/etexcmds.sty
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/ifluatex.sty))))
(/opt/texlive/2016/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix 
<2008/02/07> (tvz)) (/opt/texlive/2016/texmf-dist/tex/latex/float/float.sty)
(/opt/texlive/2016/texmf-dist/tex/latex/base/ifthen.sty)
(/opt/texlive/2016/texmf-dist/tex/latex/tools/calc.sty)
(/opt/texlive/2016/texmf-dist/tex/latex/ifplatform/ifplatform.sty
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/luatex-loader.sty
(/opt/texlive/2016/texmf-dist/scripts/oberdiek/oberdiek.luatex.lua)))
(/opt/texlive/2016/texmf-dist/tex/generic/oberdiek/catchfile.sty)
uname -s > "test.w18"

! Package catchfile Error: File `test.w18' not found.

See the catchfile package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.93     \CatchFileDef\@tempa{\ip@file}{}

? 

As mentioned, it's a freshly installed TeX Live 2016; I've also checked the installed Pygmentize version, which is 2.1.3 (installed via pip). Testing with TeX Live 2015, the above code, however, works without problems with both pdflatex and lualatex.

Does anybody have a hint for me on how to fix this, or is it a bug in lualatex or minted (or whatever other package) that should be reported?

Update: With minted version 2.2 (2016-06-08), the package loads the shellesc package automatically, as mentioned by @David Carlisle and @egreg in the comments; therefore, the problem should not occur any more, if you have this version installed.

  • It's a bug (probably in minted or catchfile). With TL2016 there came a new version of LuaTeX (0.95.0). Some packages might not yet have caught up on the changes. – Henri Menke Jun 6 '16 at 8:57
  • I can't use minted and test but my first try would be \usepackage{shellesc}, the second \usepackage{luatex85} (before minted). The file w18 is from ifplatform.sty, so the problem is there. – Ulrike Fischer Jun 6 '16 at 9:05
  • 2
    This is fixed in minted's github github.com/gpoore/minted – David Carlisle Jun 6 '16 at 9:47
  • 3
    The new version of minted is in TL 2016 as of today – user31729 Jun 11 '16 at 6:39
16

Several packages using \write18 will need to be updated for compatibility with LuaLaTeX under LuaTeX 0.90; minted is among them.

However, the shellesc package provides the necessary workaround:

\documentclass{article}
\usepackage{shellesc}
\usepackage{minted}

\begin{document}

\begin{minted}{ruby}
class Foo
  def init
    pi = Math::PI
    @var = "Pi is approx. #{pi}"
  end
end
\end{minted}

\end{document}

(credit to ArTourter for noting it).

Here's a set of patches that replace all appearances of \immediate\write18 with \ShellEsc, the safer way without relying on redefinitions of \write.

These patches don't need LuaLaTeX at all, so the code works with all engines.

\documentclass{article}
\usepackage{shellesc,xpatch}
\usepackage{minted}

\makeatletter
\xpatchcmd{\DeleteFile}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\DeleteFile}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\ProvideDirectory}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\TestAppExists}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\TestAppExists}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\minted@checkstyle}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\minted@checkstyle}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\minted@checkstyle}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\minted@checkstyle}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\minted@pygmentize}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\minted@pygmentize}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\minted@pygmentize}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\minted@pygmentize}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd{\minted@pygmentize}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\makeatother

\begin{document}

\begin{minted}{ruby}
class Foo
  def init
    pi = Math::PI
    @var = "Pi is approx. #{pi}"
  end
end
\end{minted}

\end{document}

enter image description here

Note: I can't check the patches on Windows, so they might not be complete in that case.

Shorter code is available if one uses regexpatch:

\documentclass{article}
\usepackage{shellesc,regexpatch}
\usepackage{minted}

\makeatletter
\xpatchcmd*{\DeleteFile}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd*{\ProvideDirectory}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd*{\TestAppExists}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd*{\minted@checkstyle}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\xpatchcmd*{\minted@pygmentize}
  {\immediate\write18}
  {\ShellEscape}
  {}{}
\makeatother

\begin{document}

\begin{minted}{ruby}
class Foo
  def init
    pi = Math::PI
    @var = "Pi is approx. #{pi}"
  end
end
\end{minted}

\end{document}
  • 4
  • I have been using it with shellesc only, without the patches and it works fine. I think the shellesc package does the patching for you. – ArTourter Jun 6 '16 at 10:45
  • @ArTourter Yes, but the patches don't rely on the redefinition of \write (more a suggestion for G. Poore, I'd say). – egreg Jun 6 '16 at 10:46
  • @egreg the new minted won't rely on the \write definition either as it uses \ShellEscape in the code replacing all the previous \write18 calls so it will expand straight to \directlua{os.exec in new luatex. – David Carlisle Jun 6 '16 at 13:29
  • 1
    @egreg Thanks for your quick help. The shellesc package did the fix for me. As it is already in minteds GitHub, I think it will be available via CTAN (and TL updates) as well in the near future. – Stephan Lukasczyk Jun 6 '16 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.