RMD caching used to work well for me and the same cache was used whether I clicked the Knit
button or typed rmarkdown::render("document.Rmd")
in the console. Recently (perhaps after an update) something has changed and the two ways of rendering the document produce incompatible caches. Here is a test document cache_test.Rmd
:
---
title: "Test"
output: html_document
---
```{r setup}
knitr::opts_chunk$set(cache = TRUE)
```
```{r test}
Sys.sleep(5)
x <- 1
```
In Ubuntu (18.04) when I click Knit
button a cache is created and the second click renders the document very fast. However, if I type
rmarkdown::render("cache_test.Rmd")
it re-creates all the cache and the code is executed again. Repeated render
uses this cache and renders the document quickly. But then, when I click Knit
button it takes 5 seconds again and the cache is re-created. Button and command erase each others cache.
The cache file names are test_5a1706c1d791f935f5f22a477627baf4
for console command and test_5047c0b46adf81541467741d6cc9aa4f
for the Knit
button. These names are consistent, that is, in every iteration of button/command the same two names appear. They never exist together, when 'button file' is created, the 'command file' is deleted and vice versa.
This is a new phenomenon, I have used both Knit
button and the command line on the same cache for many years, now it stopped working. To make things even more puzzling, when I perform the same test on my Mac, the cache works well both for the button and the command. I use the same version of R (3.6.2) and RStudio 1.2.5033 on both machines.
Below, session info for the offending Ubuntu installation.
> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.2 magrittr_1.5 rsconnect_0.8.16 htmltools_0.4.0 tools_3.6.2 yaml_2.2.0
[7] Rcpp_1.0.3 codetools_0.2-16 stringi_1.4.5 rmarkdown_2.0 knitr_1.26 stringr_1.4.0
[13] digest_0.6.23 xfun_0.11 rlang_0.4.2 evaluate_0.14