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)
```
cderv
February 17, 2023, 11:24am
2
For reference this was also posted here
opened 04:04PM - 30 Jan 23 UTC
closed 07:13PM - 01 Feb 23 UTC
bug
third-party
### Bug description
**Note:** I [reported this](https://community.rstudio.com… /t/quarto-presentation-render-fails-on-second-try-after-deleting-cache-when-using-cache-with-leaflet-addprovidertiles/158757) over at community.rstudio.com, but I suppose that this is a better place for it.
I am using RStudio 2022.12.0 Build 353 with R version 4.2.2 Patched (2022-11-10 r83330) and knitr-1.41 on a Ubuntu 20.04.5 LTS installation.
I have identified a problem using `cache: true` in a quarto document that uses the `leaflet` package, specifically when using `addProviderTiles`. An example document that demonstrates the problem is below:
````
---
title: "test"
format: revealjs
---
## Create some random spatial data
```{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)
```
````
The document renders without problem the first time before the `cache` exists, but the second time it fails with the following error about missing dependencies:
```
Error: path for html_dependency not found: /tmp/RtmpXpw2HT
Execution halted
```
Deleting the cache allows it to render again, but one looses the `cache` functionality.
### Checklist
- [X] Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report.
- [X] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] Please document the operating system you're running. If on Linux, please provide the specific distribution.
and this is from leaflet
opened 07:07PM - 01 Feb 23 UTC
closed 02:13PM - 13 Oct 23 UTC
Take this document
````markdown
---
title: "test"
output: html_document
… ---
```{r}
library(leaflet)
```
```{r, cache = TRUE}
m <- leaflet() %>% setView(lng = -71.0589, lat = 42.3601, zoom = 12)
m %>% addProviderTiles(providers$OpenTopoMap)
```
````
We'll get an error like this
````
Error:
! path for html_dependency not found: C:/Users/chris/AppData/Local/Temp/RtmpaOTxJr
Backtrace:
▆
1. └─rmarkdown::render("C:/Users/chris/Documents/test.Rmd", encoding = "UTF-8")
2. └─output_format$pre_processor(...)
3. └─rmarkdown (local) base(...)
4. └─rmarkdown:::html_extras_for_document(...)
5. └─rmarkdown (local) dependency_resolver(all_dependencies)
6. └─base::lapply(dependencies, validate_html_dependency)
7. └─rmarkdown (local) FUN(X[[i]], ...)
8. └─rmarkdown:::stop2("path for html_dependency not found: ", file)
````
I believe this is directly related to https://github.com/rstudio/leaflet/issues/732. Not using a temp file in the HTML dependency should solves this issue.
This came initially in https://github.com/quarto-dev/quarto-cli/issues/4149
@schloerke I believe we already discussed on something related some time ago, but can't find a reference to it. Maybe you'll remember
system
Closed
March 10, 2023, 11:24am
3
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.