Problem and context
I have a shell script that downloads markdown files from a Gitlab wiki, does some pandoc filtering and then converts it to a PDF.
The conversion to PDF happens with pandoc, which uses LaTeX in the background. For some reason when I specify latexmk in the --pdf-engine option the script fails.
Command and error
If I run pandoc mwe.tex --pdf-engine=latexmk -o ./mwe.pdf the process fails and pdflatex.log shows:
INFO pdflatex - this process (2200) started by 'sh' with command line: "C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe" -interaction=batchmode -halt-on-error -interaction=batchmode -recorder -output-directory=C://Users/username/AppData/Local/Temp/tex2pdf.-f71f6aebf5dc3db8 C://Users/username/AppData/Local/Temp/tex2pdf.-f71f6aebf5dc3db8/input.tex
INFO pdflatex - allowing known shell commands
INFO pdflatex - enabling input (output) from (to) processes
INFO pdflatex - setting output directory: C:/Users\username\AppData\Local\Temp\tex2pdf.-f71f6aebf5dc3db8
INFO pdflatex - setting aux directory: C:/Users\username\AppData\Local\Temp\tex2pdf.-f71f6aebf5dc3db8
ERROR pdflatex.core - Access is denied.
ERROR pdflatex.core - Function: FindFirstFileExW
ERROR pdflatex.core - Result: 5
ERROR pdflatex.core - Data: directory="C:$Recycle.Bin\S-1-5-18"
ERROR pdflatex.core - Source: Libraries\MiKTeX\Core\DirectoryLister\win\winDirectoryLister.cpp:135
FATAL pdflatex - Windows API error 5: Access is denied.
FATAL pdflatex - Info: directory="C:$Recycle.Bin\S-1-5-18"
FATAL pdflatex - Source: Libraries\MiKTeX\Core\DirectoryLister\win\winDirectoryLister.cpp
FATAL pdflatex - Line: 135
INFO pdflatex - this process (2200) finishes with exit code 1
WARN miktex.core - still open: C://Users/username/AppData/Local/Temp/tex2pdf.-f71f6aebf5dc3db8/input.tex
WARN miktex.core - still open: C:/Users\username\AppData\Local\Temp\tex2pdf.-f71f6aebf5dc3db8\input.log
What I've tried
Running latexmk -pdf mwe.tex works as expected.
Running pandoc mwe.tex --pdf-engine=xelatex -o ./mwe.pdf works as expected.
This previous question mentions that permissions should be set correctly. I've checked, and my user has Full Control permissions on c:\Program Files\MiKTeX 2.9\ and c:\Users\username\AppData\Local\Temp\ folders.
However, the error states that the folder C:\$Recycle.Bin\S-1-5-18 is causing trouble, which only has permissions for the SYSTEM user.
That raises the question: why does pdflatex wants to access the SYSTEM recycle bin instead of my users recycle bin?
MWE
My MWE is found below:
\documentclass[]{article}
\title{Title}
\author{Author}
\date{Month 00, 1984}
\begin{document}
\maketitle
Some content
\end{document}
pandoc mwe.md -o .mwe.tex; latexmk -pdf mwe.tex? – Fran Sep 17 '20 at 05:22bibermisbehaving similarly when used in user-controlled windows environment.latexmkandbiberare both perl (but the similarity ends there). Try to work as suggested by @Fran ; othewise you would have to do some changes forpar-packerif you really insist on one step process withlatexmk– Tomáš Kruliš Sep 17 '20 at 07:20mwe.mdwith a YALM header with title: xxx, author: yyy, date: date: zzz and output: pdf_document, and only "Some content " as document text, andpandoc --pdf-engine=latexmk mwe.md -o mwe.pdfworks without any problem. – Fran Sep 17 '20 at 21:05C:\$Recycle.Bin\S-1-5-18) is not accessible to my user, but that is at it should be. Not sure why pdflatex wants to access it though. – Saaru Lindestøkke Sep 17 '20 at 21:28-output-directory=dir(or-outdir=dir) option of latemk. That is, try withpandoc test.tex --pdf-engine=latexmk --pdf-engine-opt=-output-directory=. -o mwe.pdf. – Clément Oct 29 '21 at 18:17