Where to target troubleshooting saving Rmarkdown PDF from shiny app

I have a shiny app running on a shiny server on a linux-Ubuntu box. It has a button to generate a Rmarkdown pdf report. If I run the app from the shiny server's Rstudio url, it works fine as many times in a row as I want to make changes and generate pdf reports. If I run the app from the shiny server by its direct url, it will work after a server reset, but then offer and fail to download a .txt every time you try the button after the first success.

The first time there is no error log generated, on the following failed attempts the log gives this error every time:

processing file: 07_MarkdownTemplate.Rmd
output file: 07_MarkdownTemplate.knit.md

! LaTeX Error: Missing \begin{document}.

Warning: Error in : LaTeX failed to compile /tmp/Rtmp5GMGAm/filefd2e7c39874a.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See filefd2e7c39874a.log for more info.
[No stack trace available]

processing file: 07_MarkdownTemplate.Rmd
output file: 07_MarkdownTemplate.knit.md

! LaTeX Error: Missing \begin{document}.

Warning: Error in : LaTeX failed to compile /tmp/Rtmp5GMGAm/filefd2e31db764c.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See filefd2e31db764c.log for more info.
[No stack trace available]


I did not find the tips at https://yihui.org/tinytex/r/#debugging to be helpful. I'm looking for a place to kick off my troubleshooting. Since it works every time from the shiny servers rstudio instance, it makes me think there is something different between the R or Packages that it and the server have access to. How would I check that? I'm at a lost for where to start look for info on this, or how to get the knitting to work every time.