(Possibly related to this, but the example and the error are very different from what I've come up with. Plus it's a question from 2015, and the answers have been updated in 2017 and no later, so I expect things might have changed in the meanwhile.)
Here's a MWE
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{
external,
tikzmark
}
\tikzexternalize[only named=true, prefix=externalized/]
\begin{document}
\tikzsetnextfilename{green}
\tikz{\draw[fill=green] (0,0) circle (12pt);}\dots
A node: \tikzmarknode{NodeName}{TikZ mark node}
% the following env is not actually necessary to trigger the error
\begin{tikzpicture}[remember picture, overlay]
\node[yshift=-0.9em] at (NodeName) {some text under it};
\end{tikzpicture}
\end{document}
which errors like this
...
===== Image 'externalized/green' is up-to-date. ======
! Package tikz Error: Giving up on this path. Did you forget a semicolon?.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.16 A node: \tikzmarknode{NodeName}{TikZ mark node}
[1{/usr/local/texlive/2023/texmf-var/fonts/map/pdftex/updmap/pdftex.map}<./exte
rnalized/green.pdf>] (./externalizing.aux))
(see the transcript file for additional information)
413 words of node memory still in use:
3 hlist, 1 vlist, 1 rule, 2 glue, 3 kern, 1 glyph, 5 attribute, 48 glue_spec
, 5 attribute_list, 2 write nodes
avail lists: 2:179,3:87,4:10,5:24,6:4,7:196,9:78,11:2
</usr/share/fonts/OTF/lmroman10-regular.otf>
Output written on externalizing.pdf (1 page, 5387 bytes).
SyncTeX written on externalizing.synctex.gz.
Transcript written on externalizing.log.
As the example should suggest, in my actual usecase, I use \tikzmarknode to have a way to position a tikz node with some text with respect to inline text. I'm not interested in externalizing this picture, even because it would not make sense, I think, as all it does is provide positioning.
However, I do have other "ordinary" TikZ picture around that I do want to externalize.
Therefore, the fact that commenting \tikzexternalize is enough to avoid the error is clearly not viable.
The obvious solution, which I'm adopting so far, is to enclose every usage of \tikzmarknode+tikzpicture within \tikzexternaldisable and \tikzexternalenable, like this:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{
external,
tikzmark
}
\tikzexternalize[only named=true, prefix=externalized/]
\begin{document}
\tikzsetnextfilename{green}
\tikz{\draw[fill=green] (0,0) circle (12pt);}\dots
\tikzexternaldisable
A node: \tikzmarknode{NodeName}{TikZ mark node}
% the following env is not actually necessary to trigger the error
\begin{tikzpicture}[remember picture, overlay]
\node[yshift=-0.9em] at (NodeName) {some text under it};
\end{tikzpicture}
\tikzexternalenable
\end{document}
However, I'm wondering why is that, and whether there's a better solution than disseminating \tikzexternaldisable and \tikzexternalenable around.
Furthermore, since I use only named=true, I don't understand why TikZ should attempt any externalization at all when meeting a \tikzmarknode.
From tlmgr gui I see that the table Local rev. (ver.) for tikzmark is 64819 (1.15).