I'm currently trying to get my thesis to compile with latexmk. I am running WSL (Ubuntu 18.04) on a Windows 10 Machine. My file structure is as follows:

+-- build/
+-- src/
|   +-- 01_intro.tex
|   +-- 02_dynamics.tex
|   +--- ....... (several of these *.tex files)
|   +-- references.bib
|   +-- aiaa.bst
|   +-- thesis.cls
+-- main.tex

And I am running latexmk -output-directory="build" -pdf main.tex

It begins compiling, and then mid-way through the process it seems to throw an error, which reads as follows:

No file main.toc.
No file main.lof.
No file main.lot.
[6] [7]
! I can't write on file `src/01_intro.aux'.
\@include ...\immediate \openout \@partaux #1.aux 
                                                  \immediate \write \@partau...
l.74 \include{\chapterPath/01_intro}
(Press Enter to retry, or Control-D to exit; default file extension is `.tex')
Please type another output file name: 

The strange thing is, if I simply enter Ctrl-D, it seems to finish compiling. With all of the files in the build/ directory (or build/src/ if their corresponding .tex file was in src/). The final PDF looks correct, though its also difficult to say for sure whether the compliation is working perfectly as this is just a template at the moment (I am just setting up my thesis at the moment). If I modify any of the chapters and recompile, there are no issues, so long as I don't delete any of the .aux files in build/.

Does anyone have any idea what I'm doing wrong, and why I am getting this prompt?


If you examine the output from latexmk, just after the first aborted run of pdflatex, you should see a message from latexmk:

Latexmk: Directory 'build/src' created
Error in *LaTeX, but needed subdirectories in output directory
    were missing and successfully created, so try again.

The problem is that the directory build/src/ didn't exist before the first run of pdflatex, and pdflatex does not itself create the directory. Hence it gives an error. If you had created the directory build/src before starting latexmk, there would be have been no error.

But latexmk is programmed to detect this situation (from pdflatex's log file) and correct it. After that everything works properly, as you found.

  • Ahh wonderful! Thanks so much!
    – Chris Gnam
    Feb 24 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.