[Tex/LaTex] Cannot run tikz externalize with lualatex but it used to work

luatextikz-external

I'm trying to use the TikZ externalization library using lualatex (because of various needs). It used to work with no problems (say about 1.5 years ago), but I've now upgraded – I'm on Debian testing, so have TeX Live 2016, luatex announcing itself as "This is LuaTeX, Version 1.0.0 (TeX Live 2016/Debian) (format=lualatex 2017.3.20) 20 APR 2017 20:31". I have tried this simplest of files, the first example taken from the TikZ externalization documentation library.

\documentclass{article}
% main document, called main.tex
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize % activate!
\begin{document}
\loggingall
\begin{tikzpicture}
  \node {root}
    child {node {left}}
    child {node {right}
      child {node {child}}
      child {node {child}}
    };
\end{tikzpicture}

A simple image is \tikz \fill (0,0) circle(5pt);.
\end{document}

When I run "pdflatex –shell-escape main", it works fine, but when I replace pdflatex with lualatex, it bombs out with:

! Package tikz Error: Sorry, the system call 'lualatex -shell-escape -halt-on-e
rror -interaction=batchmode -jobname "main-figure1" "\def\tikzexternalrealjob{m
ain}\input{main}"' did NOT result in a usable output file 'main-figure1' (expec
ted one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system c
alls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also name
d 'write 18' or something like that. Or maybe the command simply failed? Error 
messages can be found in 'main-figure1.log'. If you continue now, I'll try to t
ypeset the picture.

Does anyone have any idea what might be wrong here? "lualatex –shell-escape" itself works fine (I tried it on a trivial file), and running 'lualatex -shell-escape -halt-on-error -interaction=batchmode -jobname "main-figure1" "\def\tikzexternalrealjob{main}\input{main}"' directly from a command line seemed to work ok, if that means anything.

Thanks!

Best Answer

You need the shellesc package

\documentclass{article}
\usepackage{shellesc}
% main document, called main.tex
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize % activate!
\begin{document}
\loggingall
\begin{tikzpicture}
  \node {root}
    child {node {left}}
    child {node {right}
      child {node {child}}
      child {node {child}}
    };
\end{tikzpicture}

A simple image is \tikz \fill (0,0) circle(5pt);.
\end{document}
Related Question