Closed cderv closed 1 year ago
I am still unsure what was the change that breaks Quarto, but as this was really problem, quarto is now ensuring that the directory exists before calling the htmltools function. https://github.com/quarto-dev/quarto-cli/commit/2e9a92cdc9bacb6751515b24e0e1582ed8150f1c
or maybe I am looking in the wrong place. I am not convinced yet, so still look, but sharing now with you in case it can help
A git bisect confirmed me that #276 merge is what created the issue.
In fact the issue is :
OuputDir
is set to a path (folder with subfolder)dir.create()
as they did not have recursive = TRUE
https://github.com/rstudio/htmltools/blob/6a03c3f35fbe6bfd0f91ba0607808a2b9127c5e5/R/html_dependency.R#L336-L337
https://github.com/rstudio/htmltools/blob/6a03c3f35fbe6bfd0f91ba0607808a2b9127c5e5/R/html_dependency.R#L353-L354
With quarto this lead to two warnings thrown by dir.create()
dir.create()
was called again with recursive = TRUE
in here
https://github.com/rstudio/htmltools/blob/6a03c3f35fbe6bfd0f91ba0607808a2b9127c5e5/R/html_dependency.R#L372-L383
Hence why everything is copied in the right place. normalizePath
does not work
https://github.com/rstudio/htmltools/blob/63ec24dc2b163fd99a8f82a272cb4235beaa5573/R/html_dependency.R#L357That is what is causing the issue with 0.5.3 where it was working with 0.5.2
Hope it helps know what to do.
Reprex with R Markdown by changing lib_dir
(easier to debug than quarto)
---
title: "Untitled"
output:
html_document:
self_contained: false
lib_dir: test_files/libs
---
## Title
```{r}
mtcars |>
kableExtra::kbl()
Thanks for the analysis @cderv. I think that copyDependencyToDir()
should create outputDir
recursively, I added a fix for this in #332.
Thanks @gadenbuie for the PR !
I believe the change in https://github.com/rstudio/htmltools/pull/276 and new 0.5.3 version broke Quarto rendering with HTML dependencies.
Using latest CRAN version, inside a new project with this document
test.qmd
output file: test.knit.md
Error in
normalizePath()
: ! path[1]="test_files\libs/kePrint-0.0.1": Le chemin d’accès spécifié est introuvable Backtrace: ▆Quarto is passing
test_files\\libs
tooutputDir
incopyDependencyToDir()
and with the recent change, iftest_files
does not exist, it will error this way. Creatingtest_files
folder before rendering, or installing htmltools 0.5.2 will make this example works.For the change in #276, I think there could have been some side effect where https://github.com/rstudio/htmltools/blob/6a03c3f35fbe6bfd0f91ba0607808a2b9127c5e5/R/html_dependency.R#L336-L337 was throwing a warning anyway as
recursive = TRUE
is not set. With 0.5.2 I am seeingBut the document is still rendering correctly.
Could we set
recursive = TRUE
foroutputDir
creation maybe ?Or should
outputDir
not be set to a path, but just a folder name ? In that case this would be to change in Quarto. The fact I see warning in both 0.5.2 and 0.5.3 makes me wonder. it is just working with dependencies copied in 0.5.2 but erroring with 0.5.3or maybe I am looking in the wrong place. I am not convinced yet, so still look, but sharing now with you in case it can help
cc @gadenbuie as you made the changed. Seems like some side effect here going on.