Cleanup tmpdir for rmarkdown documents with runtime shiny

In an rmarkdown document you can specify runtime: shiny to get an interactive report. Great. However, cleanup of the tempdir is done only at the end of the shiny session (ie. when the last browser tab of the last user closes). This means that with every refresh of the page, the entire bootstrap template (~4MB) and a few other files are copied to the tempdir by knitr, which quickly fills up the tmp partition on my server. Cleanup at the end of the session works most of the time, but it seems that for certain edge cases cleanup never happens.

For an output: html_document one can specify lib_dir: lib_dir which mitigates some of the problem, as the bootstrap template is now served from lib_dir and only some smaller intermediate files are copied to the tmp_dir upon refresh of the shiny page. For a small number of users this is fine.

However, if one changes the output to output: flex_dashboard, this setting is not honoured. Or rather, the bootstrap template is still copied to the tempdir for every refresh.

It seems to me that I have two issues:

  • A feature request to clean up the tempdir during the shiny session, rather than only at the end.
  • A bug with how the flexdashboard lib_dir option is implemented.

Unfortunately, I can't figure out where I should leave the feature request or the issue. Is it the github repository for Shiny, RMarkdown, Knitr, or Flexdashboard?

Or is there a problem with my implementation? All my tests have been done on linux shiny installations with different package versions. I can't find any changes in any of the aforementioned packages which might suggest a combination of versions would or would not work. No relevant work on the temp files for shiny, knitr, rmarkdown, or flexdashboard appears to have happened in the past years.

A reproducible example:

---
title: "Tmp dir filling up"
runtime: shiny
output: 
    flexdashboard::flex_dashboard
---

```{r}
print(system(paste("ls -thrall", tempdir()), intern=TRUE))
```

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.