Error using tikz externalize: can't write md5 file

Your issue occurs because you are using the flag -output-directory=build when running pdflatex.


In order to makes explanations less ambiguous, let's rename folders:

  • you are using the flag -output-directory=foo;
  • your .tex file is in a folder named root;
  • you are using following macro in your .tex file: \tikzexternalize[prefix=bar/].

What happens is that the externalization creates .pdf (as well as .log and .dpth files) in the folder root/bar/. However, the externalization also creates "output files" (actually .md5) and thus stores them into... root/foo/bar.

The error is raised because the folder root/foo/bar doesn't exist on your computer (you only have created root/bar). Creating it should solve the problem.