# How to fix undefined references when using latexmk with auxdir

I'm having a hard time figuring this out. Using a very simple document, compiling with the auxdir option results in an undefined reference (latexmk report --pdf -auxdir=export). Without the auxdir argument it works just fine (latexmk report --pdf). I've also tried this without the --pdf option, and the results are the same. Any ideas to determine what's causing this would be appreciated.

Document used:

\documentclass[11pt]{article}

\begin{document}
\section{Section}\label{sec:one}
Section \ref{sec:one} is broken...
\end{document}


I've done some searching, and the auxdir option seems to cause trouble with glossaries and bibliographies (e.g. Latexmk with makeglossaries and auxdir and outdir?), but nothing on references.

edit: Partial compiler output

Latexmk: This is Latexmk, John Collins, 1 January 2015, version: 4.41.
Latexmk: making auxiliary directory 'test2'
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex': Rules & subrules not known to be previously run:
pdflatex
Rule 'pdflatex': The following rules & subrules became out-of-date:
'pdflatex'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex  -recorder -aux-directory="test2"  "report.tex"'
------------
pdflatex: unrecognized option '-aux-directory=test2'
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode

• If you want to stay sane, don't use auxdir! – Snobbish Hi-rep users Apr 25 at 19:03
• @valerie, that's the impression I'm starting to get... Especially if it doesn't handle something as simple as this. – user2699 Apr 25 at 19:27
• What is your motivation for wanting to use auxdir? Maybe there is another solution? – Snobbish Hi-rep users Apr 25 at 19:29
• @valerie, mostly just to keep the directory with my main file a little bit cleaner. – user2699 Apr 25 at 19:31
• @DavidCarlisle A number of us really disagree on the auxdir and outdir options. We find it a lot more convenient to have generated files in a different directory. But ultimately that's a matter of personal preference, of course. However, if you are using latexmk, there's absolutely no need to reconfigure a tool chain. Latexmk with -auxdir or -outdir does robustly take care of everything, in every case I know of. So as I said in another comment, the real problem is elsewhere. – John Collins Apr 25 at 20:29