TeX Live 2016: minted は LuaLaTeX では動作しません (2016 年 6 月にバグ修正)

TeX Live 2016: minted は LuaLaTeX では動作しません (2016 年 6 月にバグ修正)

本日リリースされた TeX Live 2016 をインストールしました (開発者に感謝します)。

現在、次の 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}

実行すると、pdflatex --shell-escape test.texファイルが実行され、期待どおりにPDFが生成されます。同じことをするとlualatex --shell-escape test.tex

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}{}

? 

前述のとおり、これは新しくインストールされた TeX Live 2016 です。また、インストールされている Pygmentize のバージョンも確認しましたが、これは 2.1.3 (pip 経由でインストール) です。ただし、TeX Live 2015 でテストすると、上記のコードは pdflatex と lualatex の両方で問題なく動作します。

これを修正する方法についてヒントを持っている人はいますか、それともこれは lualatex または minted (またはその他のパッケージ) のバグであり、報告する必要があるのでしょうか?

アップデート:mintedバージョン 2.2 (2016-06-08)では、 shellesc@David Carlisle と @egreg がコメントで述べているように、パッケージは自動的にロードされます。したがって、このバージョンがインストールされている場合は、問題は発生しなくなるはずです。

答え1

を使用するいくつかのパッケージは、\write18LuaTeX 0.90 の LuaLaTeX との互換性を保つために更新する必要があります。mintedその中に があります。

ただし、shellescパッケージには必要な回避策が用意されています。

\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}

(これを指摘してくれたArTourterに感謝します)。

以下は、 の再定義に頼らずに、より安全な方法で、のすべての出現を\immediate\write18に置き換えるパッチのセットです。\ShellEsc\write

これらのパッチは LuaLaTeX をまったく必要としないため、コードはすべてのエンジンで動作します。

\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}

ここに画像の説明を入力してください

注: Windows ではパッチを確認できないため、その場合はパッチが完全ではない可能性があります。

次を使用すると、より短いコードが利用できます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}

関連情報