# Problems getting Tikz externalisation to work even on a simple file (LuaTeX) [duplicate]

I am out of my depths to understand what could be going wrong here. I am using luatex (TL 2018) to compile a simple pgfplot example.

This is the error message I get

example_surf.tikz:8: Package tikz Error: Sorry, the system call 'lualatex -shell-escape -halt-on-error -interaction=batchmode -jobname "main-figure0" "\def\tikzexternalrealjob{main}\input{main}"' did NOT result in a usable output file 'main-figure0' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or something like that. Or maybe the command simply failed?

This is strange, because in my latexmkrc I have

$pdflatex = 'lualatex %O %S --shell-escape';$pdf_mode = 1;
$postscript_mode =$dvi_mode = 0;


Clearly, we can see that shell-escape is enabled.

Here is a MNWE.

\RequirePackage{luatex85,shellesc}  % not sure if this is required
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{grffile}
\usetikzlibrary{plotmarks}
\usetikzlibrary{arrows.meta}
\usepgfplotslibrary{patchplots}
\usepackage{amsmath}
\usepgfplotslibrary{external}
\tikzset{external/force remake}
\tikzexternalize

\begin{document}

\input{example_surf.tikz}

\end{document}


The file example_surf.tikz is a simple 3D surface plot from the pgfplots manual.

\begin{tikzpicture}
\begin{axis}

• @UlrikeFischer thank you very much. Sorry that I could not figure out it was due to class mismatch. What happened was I generated some figure from matlab2tikz, which uses this document class. Later on, I tried to convert this to an externalised setup. Your pointer helps to solve the issue. – Krishna Jun 7 '18 at 15:25