Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
dmkaplan2000 opened this issue Jan 30, 2023 · 15 comments
Assignees
Labels
bug Something isn't working third-party Issues involving interaction with a third-party library

Comments

@dmkaplan2000
Copy link

dmkaplan2000 commented Jan 30, 2023

Bug description

Note: I reported this 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

  • 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.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.
@dmkaplan2000 dmkaplan2000 added the bug Something isn't working label Jan 30, 2023
@cscheid
Copy link
Collaborator

cscheid commented Jan 31, 2023

@cderv Maybe you have expertise here? I'm not familiar with how the knitr cache works.

@dmkaplan2000
Copy link
Author

I should note that I converted this presentation from Rpres format to qmd and that is when I noted the problem. As an Rpres presentation, it worked fine.

@cderv
Copy link
Collaborator

cderv commented Jan 31, 2023

It is happening with R Markdown too. So definitely something going on leaflet, knitr and/or rmarkdown. I don't think it is directly Quarto related. I'll look closer to debug. thanks for the report !

@cderv cderv added upstream Bug is in upstream library third-party Issues involving interaction with a third-party library and removed upstream Bug is in upstream library labels Jan 31, 2023
@cderv cderv moved this to Quarto related in R Markdown Team Projects Jan 31, 2023
@cderv cderv moved this from Quarto related to Next in R Markdown Team Projects Jan 31, 2023
@dmkaplan2000
Copy link
Author

I only tried Rpres (where it worked, or at least it didn't create an error) and Quarto (where it did not), so can't say for Rmarkdown...

@cderv
Copy link
Collaborator

cderv commented Feb 1, 2023

@dmkaplan2000 this is an issue with how leaflet HTML dependency for using tile providers works (loaded by addProviderTiles). I opened an issue there rstudio/leaflet#843 and you can look at linked one there too.

It using a temp file in a R temporary directory which does not exists anymore in a following render. So cache won't find the HTML dependency.

I don't exactly know why you don't get error with Rpres though. Maybe because caching works a bit specifically between rendering that in Rmd or Qmd with knitr

Anyway, you can follow there - I'll close this on Quarto side.

Thanks for the report!

@cderv cderv closed this as completed Feb 1, 2023
@github-project-automation github-project-automation bot moved this from Next to Done in R Markdown Team Projects Feb 1, 2023
@eroten
Copy link

eroten commented Mar 23, 2023

For anyone looking for a workaround in quarto before gets rstudio/leaflet#843 resolved , try adding screenshot.force: true in the knitr options in _quarto.yml

 knitr: 
      opts_knit: 
        always_allow_html: yes
      opts_chunk: 
          screenshot.force: true

@ericvmai
Copy link

ericvmai commented Oct 5, 2023

I'm still getting this issue and Leaflet for R hasn't provided a solution. How can you stop leaflet providers from trying to use a temp file?

@michelk
Copy link

michelk commented Mar 12, 2024

This bug persists.

@mcanouil
Copy link
Collaborator

@michelk could you open an issue mentioning this one and provide sufficient information as requested in the bug report template? Thank you.

@cderv
Copy link
Collaborator

cderv commented Mar 12, 2024

@michelk please to update all of your R packages related to this issue.

it has been fixed upstream in leaflet version 2.2.1 and leaflet.providers version 2.0.0

Be sure to have those versions installed.

You can follow all the related links from the leaflet issue report linked above to see how this has been fixed.

Hope this helps

@michelk
Copy link

michelk commented Mar 12, 2024

@cderv Thanks for coming back to me.

I still have the problem. Here is an example:

---
title: Test Document
date: today
lang: de
execute: 
    echo: false
    warning: false
    cache: true
---

# un

```{r}
library(mapview)
mapview(breweries, layer.name = "T1")
```

# dos
```{r}
library(mapview)
mapview(breweries, layer.name = "T2")
```

# tres
```{r}
library(plainview)

mapview(poppendorf[[5]], legend = TRUE, layer.name = "T3")
```

I get the follwing error message from quarto render tt.qmd


processing file: tt.qmd
1/7                  
2/7 [unnamed-chunk-1]
3/7                  
4/7 [unnamed-chunk-2]
5/7                  
6/7 [unnamed-chunk-3]
7/7                  
output file: tt.knit.md

Error: path for html_dependency not found: /tmp/RtmpKYVffs/data_stars36b61bb1bcd_cf9035
Execution halted

R session info

> library(leaflet)
> library(leaflet.providers)
> sessionInfo()
R version 4.3.3 (2024-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=de_CH.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=de_CH.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=de_CH.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=de_CH.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Zurich
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] leaflet.providers_2.0.0 leaflet_2.2.1          

loaded via a namespace (and not attached):
 [1] htmlwidgets_1.6.4 compiler_4.3.3    magrittr_2.0.3    fastmap_1.1.1    
 [5] R6_2.5.1          cli_3.6.2         htmltools_0.5.7   crayon_1.5.2     
 [9] crosstalk_1.2.1   digest_0.6.35     rlang_1.1.3    

@cderv
Copy link
Collaborator

cderv commented Mar 12, 2024

I can't reproduce using your file. It works for me ok.

Please try in a fresh new session, and if it happens again, open a new issue by sharing your reproducible example.

You can share using special syntax - no need to upload file always
https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us

@cscheid cscheid added the needs-repro Issues that are blocked until reporter provides an adequate reproduction label Mar 12, 2024
@michelk
Copy link

michelk commented Mar 13, 2024

Not sure what you mean with "fresh new session". I still get the error after deleting the cache files.

% rm -r tt_cache 
% rm -r tt_files 
% quarto render tt.qmd
    
    
    processing file: tt.qmd
    1/7                  
    2/7 [unnamed-chunk-1]
    3/7                  
    4/7 [unnamed-chunk-2]
    5/7                  
    6/7 [unnamed-chunk-3]
    7/7                  
    output file: tt.knit.md
    
    pandoc 
      to: html
      output-file: tt.html
      standalone: true
      section-divs: true
      html-math-method: mathjax
      wrap: none
      default-image-extension: png
      
    metadata
      document-css: false
      link-citations: true
      date-format: long
      lang: de
      title: Test Document
      date: today
      
    Output created: tt.html

% echo "# cuatro\nasdf" >> tt.qmd 
% quarto render tt.qmd           

    
    processing file: tt.qmd
    1/7                  
    2/7 [unnamed-chunk-1]
    3/7                  
    4/7 [unnamed-chunk-2]
    5/7                  
    6/7 [unnamed-chunk-3]
    7/7                  
    output file: tt.knit.md
    
    Error: path for html_dependency not found: /tmp/Rtmpg3beht/data_stars42be6bca06f7_425387
    Execution halted

@mcanouil
Copy link
Collaborator

You place your project elsewhere on your machine as if you were starting it from scratch.

@cderv
Copy link
Collaborator

cderv commented Mar 13, 2024

if it happens again, open a new issue by sharing your reproducible example.

@michelk as asked, please do open new issue. This time I have done it for you in #9058 so that we can continue discuss in its own thread.

General advice: It is usually recommended (at least within this repo) to start a new issue with reproducible examples, and updated versions of tools, instead of adding more in a thread that is closed. This one is already 1 year old!

Let's keep discussing in #9058 now - thanks

@cderv cderv removed the needs-repro Issues that are blocked until reporter provides an adequate reproduction label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working third-party Issues involving interaction with a third-party library
Projects
None yet
Development

No branches or pull requests

7 participants