You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to build articles with custom rmarkdown output formats #2319
This is a new error that has just popped up recently and that might not be entirely pkgdown's fault (but I haven't been able to track down a smaller reprex).
I have a package (cleanrmd) that provides alternative vignette output formats, which I use for vignettes in several packages.
-- RMarkdown error -------------------------------------------------------------------
Error in `map()`:
ℹ In index: 1.
Caused by error in `render_rmarkdown()` at pkgdown/R/build-articles.R:280:2:
! Failed to render RMarkdown
Caused by error:
! in callr subprocess.
Caused by error:
! 'arg' should be one of “default”, “bootstrap”, “cerulean”, “cosmo”, “darkly”, “flatly”, “journal”, “lumen”, “paper”, “readable”, “sandstone”, “simplex”, “spacelab”, “united”, “yeti”
I've put together a repo with a reprex. Within that repo, building the articles with pkgdown::build_articles() will work for the standard rmarkdown::html_vignette, but will fail for the custom method.
One (probably very relevant detail) is that removing the theme value from html_document_clean() by commenting out that line will cause the articles to build correctly. (But IIUC the custom document format should be ignored entirely during the rendering.)
pkgdown passes a special output format (docs) but at that stage it seems the one that rmarkdown uses, is the one in the document. rmarkdown:::resolve_theme("new.css") gets the error you've noticed.
This is indeed one of the latest fix at rstudio/rmarkdown#2486 that I believe trigger the issue. It is kind of side effect because
pkgdown runs its own format, and ignoring the YAML
but rmarkdown will use the YAML frontmatter of a document in its discover_rmd_resources() process
We recently added (or at least tried) to make the process more clever regarding which resource to copy when there is a bslib theme
cleanrmd::html_document_clean() has a theme argument which does not behave like a html_document_base() one, so the bslib related functions that was added a while ago to support new feature are not handling this case.
I just need to confirm this as I need to understand why exactly this happens when running in pkgdown and not just with rmarkdown. Something is triggered somehow
Anyway, I'll fix this in rmarkdown - not a pkgdown issue IMO. @gadenbuie I have ideas, but happy to discuss with you on this for possibly broader / better support for all this (bslib theme, custom formats own arguments, ...)
I just need to confirm this as I need to understand why exactly this happens when running in pkgdown and not just with rmarkdown. Something is triggered somehow
I believe this is because pkgdown is explictly calling for find_external_resources() that the issue is triggered. Otherwise, with usual rendering discover_rmd_resources() is not called. So no error shown.
which I understand pkgdown ignores anyway. It does not seem to have a been an issue until now... So is this an underlying issue to think about ?
We have the why this is triggered. About the actual error with cleanrmd, this is because of the above and the fact that resolve_theme(output_format[["theme"]])) is checked, but resolve_theme() does not handle the case where theme can be from another custom format. This is rmarkdown improvement for sure.
I guess this is working now, as not other issue reported, but I believe you are finding more resources that you need too because finding resources includes the YAML front matter content. But output YAML key is not used IIUC.
Only change to prevent "more files to be copied" (which is probably not an issue most of the time), would be to remove output key from YAML as not used at all by pkgdown. This would prevent in rmarkdown process on it.
Just to confirm: rstudio/rmarkdown#2493 does indeed solve the problem for me, both in the reprex repo and in my original repo. Thanks @maelle and @cderv!
Activity
gadenbuie commentedon Jun 8, 2023
My pkgdown CI run ran correctly about a week ago, it seems like the most likely culprit is the recent rmarkdown 2.22 release, but I don't immediately see anything relevant in the changes between 2.21 and 2.22.
Here's the diff between session info results: https://www.diffchecker.com/mNuGIyyo/
maelle commentedon Jun 9, 2023
Thanks for the reprex and investigation!
From a quick thus not thorough exploration, it seems that rmarkdown gets some information from the YAML directly
https://github.com/rstudio/rmarkdown/blob/58ca4df16a3a5c14f277b1878f9ff5b842fe1306/R/html_resources.R#LL212C3-L212C30 (I found this commit "promising")
pkgdown passes a special output format (docs) but at that stage it seems the one that rmarkdown uses, is the one in the document.
rmarkdown:::resolve_theme("new.css")gets the error you've noticed.Maybe it's actually a rmarkdown bug then? 🤔
maelle commentedon Jun 9, 2023
what I don't get is why the vignette can be rendered from RStudio IDE then?
cderv commentedon Jun 9, 2023
Thanks a lot @maelle
This is indeed one of the latest fix at rstudio/rmarkdown#2486 that I believe trigger the issue. It is kind of side effect because
discover_rmd_resources()processthemecleanrmd::html_document_clean()has athemeargument which does not behave like ahtml_document_base()one, so the bslib related functions that was added a while ago to support new feature are not handling this case.I just need to confirm this as I need to understand why exactly this happens when running in pkgdown and not just with rmarkdown. Something is triggered somehow
Anyway, I'll fix this in rmarkdown - not a pkgdown issue IMO. @gadenbuie I have ideas, but happy to discuss with you on this for possibly broader / better support for all this (bslib theme, custom formats own arguments, ...)
maelle commentedon Jun 9, 2023
Thank you @cderv 🙏
cderv commentedon Jun 9, 2023
I believe this is because pkgdown is explictly calling for
find_external_resources()that the issue is triggered. Otherwise, with usual renderingdiscover_rmd_resources()is not called. So no error shown.pkgdown/R/rmarkdown.R
Lines 62 to 70 in 39083f3
find_external_resources()will consider the YAML front matter. This is not new https://github.com/rstudio/rmarkdown/blob/10863429024e236389a48f40ab1485620d53d311/R/html_resources.R#L202-L203And so some of the resources will be discovered and handled based on the YAML of the Rmd file
which I understand pkgdown ignores anyway. It does not seem to have a been an issue until now... So is this an underlying issue to think about ?
We have the why this is triggered. About the actual error with
cleanrmd, this is because of the above and the fact thatresolve_theme(output_format[["theme"]]))is checked, butresolve_theme()does not handle the case wherethemecan be from another custom format. This is rmarkdown improvement for sure.maelle commentedon Jun 9, 2023
So is any change needed on pkgdown side? Finding external resources is useful 😁
cderv commentedon Jun 9, 2023
I guess this is working now, as not other issue reported, but I believe you are finding more resources that you need too because finding resources includes the YAML front matter content. But
outputYAML key is not used IIUC.Only change to prevent "more files to be copied" (which is probably not an issue most of the time), would be to remove
outputkey from YAML as not used at all by pkgdown. This would prevent in rmarkdown process on it.So it depends the pkgdown point of view on this.
gadenbuie commentedon Jun 9, 2023
Just to confirm: rstudio/rmarkdown#2493 does indeed solve the problem for me, both in the reprex repo and in my original repo. Thanks @maelle and @cderv!
(textproc/R-rmarkdown) Updated 2.19 to 2.29
(textproc/R-rmarkdown) Updated 2.19 to 2.29
(textproc/R-rmarkdown) Updated 2.19 to 2.29
(textproc/R-rmarkdown) Updated 2.19 to 2.29