glossaries automake not working lualatex

The problem is that with luatex (and the shellesc package) \write18 is actually an \immediate\write18 (see the documentation of shellesc). And this means that the makeindex command is executed before the acn-file has been written and closed. This is imho a bug in glossaries and should be reported.

You can patch the command like this:

\documentclass{article}

\usepackage{shellesc}
\usepackage[acronym,nomain,toc,automake]{glossaries-extra}

\setabbreviationstyle[acronym]{long-short}

\loadglsentries{glosario}

\makeglossaries

\usepackage{etoolbox}
\makeatletter
\patchcmd\@gls@automake{\write18}{\DelayedShellEscape}{}{\fail}
\makeatother
\begin{document}

\First use: \gls{CCTV}. Next use: \gls{CCTV}.
\printglossary[type=\acronymtype]
\end{document}

This will also work with pdflatex. You don't need the --shell-escape option, makeindex is in the list of safe applications.


You need to use automake=immediate in this situation. (New to glossaries version 4.22 2019-01-06.) This executes the system command at the start of \makeglossaries (before the glossary files are opened) using \immediate. You will get a warning on the first LaTeX run when the files don't exist.

With automake=true (or simply automake), the system command is executed at the end of the document, but \immediate can't be used in this case. Unlike indexes, glossaries may occur at the start of the document rather than the end, and it's possible that there are commands such as \gls on the last page. The indexing performed by these commands can't use \immediate as it can cause problems with the associated page number due to TeX's asynchronous output routine. If \write18 is called with \immediate in this case, there's a possibility that the system command may be called before the glossary files are complete.