I have identified a problem using cache: true
in a quarto document that uses the leaflet
package, specifically when using addProviderTiles
. Documents using these two in combination will initially render, but fail if rendered again complaining about missing dependencies (specifically Error: path for html_dependency not found: /tmp/RtmpXXXXXX
). An example document that demonstrates the problem is below:
---
title: "test"
format: revealjs
---
```{r}
library(sf)
library(leaflet)
# List of volcanos -----------------------------------------
v = c("Volcán Villarica, Chile","Volcán Lonquimay, Chile")
lon = c("Volcán Villarica, Chile"=-71.93,
"Volcán Lonquimay, Chile"=-71.58)
lon = lon[v]
lat = c("Volcán Villarica, Chile"=-39.42,
"Volcán Lonquimay, Chile"=-38.38)
lat = lat[v]
volcanoes = data.frame(name=v,lon=lon,lat=lat)
volcanoes = st_as_sf(volcanoes,coords=c("lon","lat"),crs=4326)
lf = volcanoes |> leaflet() |> addTiles() |> addMarkers()
```
## This works with cache
```{r}
#| cache: true
lf
```
## This fails with cache on second render
```{r}
#| cache: true
lf |> addProviderTiles(providers$OpenTopoMap)
```