Issue when creating pdf file while running knit, output file does not exist (knit-HTML is fine)



Output created: HW0.pdf
Error in tools::file_path_as_absolute(output_file) :
file 'HW0.pdf' does not exist
Calls: ->
In addition: Warning messages:
1: running command '"pdflatex" -halt-on-error -interaction=batchmode "HW0.tex"' had status 1
2: In readLines(logfile) : incomplete final line found on 'HW0.log'
Execution halted

I have no issue when running the knit-HTML, is just the pdf version.

Besides, I have checked the pdflatex is installed by running in command terminal.
it's the latest version of MikTeX.


See suggestions in the thread here:


Thank you so much, I used one of his solution on mine.
And now its working!