Error in building a book

Hi There,

When I tried to build a book chapter from a few .Rmd files (i.e. "00-preface.Rmd" , "02-data-acq.Rmd", "91-appendixA.Rmd" , "index.Rmd") using R Studio, I received the following error:

==> rmarkdown::render_site(encoding = 'UTF-8')

Error in basename(files) : a character vector argument expected
Calls: ... setdiff -> as.vector -> source_files -> grep -> basename
Execution halted

Exited with status 1.

Here is the session info:

sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252
[2] LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252

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

other attached packages:
[1] rmarkdown_2.1 tinytex_0.4

loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 rstudioapi_0.11 magrittr_1.5
[4] knitr_1.28 usethis_1.6.0 devtools_2.3.0
[7] pkgload_1.0.2 R6_2.4.1 rlang_0.4.6
[10] fansi_0.4.1 tools_3.6.3 pkgbuild_1.0.6
[13] packrat_0.5.0 xfun_0.14 sessioninfo_1.1.1
[16] cli_2.0.2 withr_2.2.0 remotes_2.1.1
[19] htmltools_0.4.0 ellipsis_0.3.0 yaml_2.2.1
[22] assertthat_0.2.1 digest_0.6.25 rprojroot_1.3-2
[25] crayon_1.3.4 bookdown_0.19.1 processx_3.4.2
[28] callr_3.4.3 fs_1.4.1 ps_1.3.2
[31] testthat_2.3.2 memoise_1.1.0 glue_1.4.1
[34] evaluate_0.14 compiler_3.6.3 backports_1.1.6
[37] desc_1.2.0 prettyunits_1.1.1

Any advice on how to solve the problem is much appreciated.

Kind regards,
Jin

I'm assuming you are following the bookdown document. In the chapter I link to, I see that a command to build the book is bookdown::render_book with a file name as argument.
What build command do you use? Is that rmarkdown::render_site(encoding = 'UTF-8') or is that command generated by the one you are using?

Thanks a lot, Han.
Yes I am following the bookdown document. With or without 'knit: "bookdown::render_book" ', it would produce the same error when I press 'Build Book' button.

It seems that I am not being able to help you any further.
But still the following suggestions:

Probably you will have seen an earlier article in the RStudio Community. That suggests checking if the Windows path contains the R executable.

Is this first time you try to create a book (with bookdown) ?
If not, what is different?

Did you start your book by creating a new 'project with bookdown' ?
If you do this now and you click on 'Build|Build_all' do you get the same error?

Thanks a lot, Han. You have already helped. Indeed it is the first time I pressed the Build Book button in my life. The problem has been solved if using Build Book|pdf_document. But when using Build|bookdown::pdf_book, a further problem is produced as it only produced a .knit.md file but not a .pdf file:

output file: Spatial-Predictive-Modelling-with-R.knit.md

File latex\before_body.tex not found in resource path
Error: pandoc document conversion failed with error 99

Thanks again for your help, Han. The problem has been solved.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.