# Origin of Lua Error

If a lualatex compilation breaks with/at this terminal output:

(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.c
ode.tex))[\directlua]:1: attempt to call a nil value (field 'get_functions_tabl
e').
l.1738   }


Does it mean the failing \directlua is in /usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.tex?

Thing is, that file does not contain a directlua. OTOH this error only started o appear after I got lualatex to read and parse an additional Lua file within my personal document infrastructure -- but I don't see anything suspicious of being related in that additional file either.

• the fragment of log you show, shows the error is not in pgfkeysfiltered.code.tex (the ) shows that file has been read to the end), but you have not shown which file the error is in. Apr 24 at 13:30

You provided no example, but given a guessed example

\documentclass{article}

\usepackage{tikz}

\begin{document}

\end{document}


The relevant part of the terminal output is

(/usr/local/texlive/2022/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.c
ode.tex))


The penultimate ) shows that pgfkeysfiltered.code.tex has been read to the end, so the final ) shown shows that pgfkeys.code.tex has been read to the end, so any line number in an error message at this point refers to the file at the top of the stack of open files, which is pgfsys.code.tex, line 1738 of which is the closing } of this \directlua call

  \directlua{
local lft = lua.get_functions_table()
lft[\string#lft+1] = function()
local lhs = token.scan_string()
local rhs = token.scan_string()
if lhs < rhs then
tex.sprint(-2, "-1")
elseif lhs == rhs then
tex.sprint(-2, "0")
else
tex.sprint(-2, "1")
end
end
token.set_lua("pgfsys@strcmp", \string#lft, "global")
}