Quarto presentation render fails on second try after deleting cache when using `cache` with `leaflet::addProviderTiles`

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)
```

For reference this was also posted here

and this is from leaflet

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.