rstudio / bookdown

Authoring Books and Technical Documents with R Markdown
https://pkgs.rstudio.com/bookdown/
GNU General Public License v3.0
3.71k stars 1.27k forks source link

R4.3 error if multiple files are passed to `render_book` without an `output_format` specified #1442

Closed slodge-work closed 9 months ago

slodge-work commented 9 months ago

This code is throwing an error in a bookdown project I'm porting to R4.3 and latest bookdown at current.

https://github.com/rstudio/bookdown/blob/3898705684ab831bc189e8d9c99e897f338e0454/R/utils.R#L416

The error is:

Error in !is.null(fallback_index) && xfun::file_exists(fallback_index) : 
  'length = 9' in coercion to 'logical(1)'

I'm afraid I can't send a repro - as I'm not sure I understand how our bookdown project works at present! However, the error is caused I think by the fact that we are passing multiple Rmds into render_book but not passing in any output_format:

bookdown::render_book(list.files(here::here("build"), pattern = "\\.Rmd$"))

This causes a vector of 9 Rmd files to be in input - and this vector is then passes as the fallback_index parameter to get_output_formats here:

https://github.com/rstudio/bookdown/blob/3898705684ab831bc189e8d9c99e897f338e0454/R/render.R#L87C1-L91C8

This then gets into the if predicate inside get_output_formats. In previous versions of R, this caused a warning - but as of R4.3 this is now an error.


We obviously have an easy workaround here within our code - we can just add an output_format:

bookdown::render_book(list.files(here::here("build"), pattern = "\\.Rmd$"), output_format = "bookdown::html_book")

... but I thought this report might help the project and future users.

Checklist

When filing a bug report, please check the boxes below to confirm that you have provided us with the information we need. Have you:

yihui commented 9 months ago

Should be fixed now. Thanks for the report!

github-actions[bot] commented 2 months ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.