rstudio / bookdown-demo

A minimal book example using bookdown
https://bookdown.org/yihui/bookdown-demo
Creative Commons Zero v1.0 Universal
499 stars 1.34k forks source link

Unable to "Build Book" use the bookdown-demo #66

Open richardgao1992 opened 2 years ago

richardgao1992 commented 2 years ago

Hello,

I just forked and cloned this repo, installed TinyTeX and tried building the book as instructed, however I encountered the following error (I got the same error before installing TinyTeX as well): processing file: bookdown-demo.Rmd |........ | 11% inline R code fragments

|................ | 22% label: unnamed-chunk-1 (with options) List of 1 $ eval: logi FALSE

|....................... | 33% ordinary text without R code

|............................... | 44% label: unnamed-chunk-2 (with options) List of 1 $ include: logi FALSE

Quitting from lines 32-36 (bookdown-demo.Rmd) Error in parse(con) : 4:12: unexpected INCOMPLETE_STRING 3: title = "Welcome to the {tidyverse}", 4: author = "Hadley Wickham, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D'Agostino McGowan, Romain Fran ^ Calls: local ... -> readCitationFile -> -> parse Execution halted Error: bookdown::render_book() failed to render the output format 'bookdown::gitbook'. Execution halted

Exited with status 1. sessionInfo

yihui commented 2 years ago

I can't reproduce this problem. Could you run bookdown::render_book() in the R console? If it throws the same error, please provide traceback() output.

richardgao1992 commented 2 years ago

bookdown::render_book() Rendering book in directory '.'

processing file: bookdown-demo.Rmd |.......... | 11% inline R code fragments

|................... | 22% label: unnamed-chunk-1 (with options) List of 1 $ eval: logi FALSE

|............................. | 33% ordinary text without R code

|...................................... | 44% label: unnamed-chunk-2 (with options) List of 1 $ include: logi FALSE

Quitting from lines 32-36 (bookdown-demo.Rmd) Error in parse(con) : 4:12: unexpected INCOMPLETE_STRING 3: title = "Welcome to the {tidyverse}", 4: author = "Hadley Wickham, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D'Agostino McGowan, Romain Fran ^ traceback() 31: parse(con) 30: tools:::.parse_CITATION_file(file, meta$Encoding) 29: readCitationFile(citfile, meta) 28: utils::citation(..., lib.loc = lib.loc) 27: citation(pkg, auto = FALSE) 26: FUN(X[[i]], ...) 25: lapply(x, function(pkg) { if (pkg == "base") return() if (system.file("CITATION", package = pkg) == "") return() cites = citation(pkg, auto = FALSE) cites = Filter(x = cites, function(cite) { !isTRUE(grepl("R package version", cite$note)) }) s = make_unique(unlist(lapply(cites, function(cite) { if (is.null(cite$year)) format(Sys.Date(), "%Y") else cite$year }))) mapply(cites, s, FUN = function(cite, suffix) { if (isTRUE(grepl("R package version", cite$note))) return() entry = toBibtex(cite) entry[1] = sub("\{,$", sprintf("{%s%s,", pkg, suffix), entry[1]) ... 24: knitr::write_bib(c(.packages(), "bookdown", "knitr", "rmarkdown"), "packages.bib") 23: eval(expr, envir, enclos) 22: eval(expr, envir, enclos) 21: eval_with_user_handlers(expr, envir, enclos, user_handlers) 20: withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)) 19: withCallingHandlers(withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)), warning = wHandler, error = eHandler, message = mHandler) 18: handle(ev <- withCallingHandlers(withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)), warning = wHandler, error = eHandler, message = mHandler)) 17: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)), warning = wHandler, error = eHandler, message = mHandler))) 16: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, debug = debug, last = i == length(out), use_try = stop_on_error != 2L, keep_warning = keep_warning, keep_message = keep_message, output_handler = output_handler, include_timing = include_timing) 15: evaluate::evaluate(...) 14: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), stop_on_error = if (is.numeric(options$error)) options$error else { if (options$error && options$include) 0L else 2L }, output_handler = knit_handlers(options$render, options)) 13: in_dir(input_dir(), expr) 12: in_input_dir(evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), stop_on_error = if (is.numeric(options$error)) options$error else { if (options$error && options$include) 0L else 2L }, output_handler = knit_handlers(options$render, options))) 11: eng_r(options) 10: block_exec(params) 9: call_block(x) 8: process_group.block(group) 7: process_group(group) 6: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group), error = function(e) { setwd(wd) cat(res, sep = "\n", file = output %n% "") message("Quitting from lines ", paste(current_lines(i), collapse = "-"), " (", knit_concord$get("infile"), ") ") }) 5: process_file(text, output) 4: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet) 3: rmarkdown::render(main, output_format, ..., clean = clean, envir = envir) 2: render_cur_session(files, main, config, output_format, clean, envir, ...) 1: bookdown::render_book()

yihui commented 2 years ago

It looks like an encoding problem. The good news is that R 4.2.0 is coming soon, which should solve most encoding problems on Windows. For now, you can try the alpha version: https://cran.r-project.org/bin/windows/base/rtest.html

cderv commented 2 years ago

Seems also a encoding issue to me. R does not manage to process this lette ç in Romain François in this reference in the bib file.

@Article{tidyverse2019,
  title = {Welcome to the {tidyverse}},
  author = {Hadley Wickham and Mara Averick and Jennifer Bryan and Winston Chang and Lucy D'Agostino McGowan and Romain François and Garrett Grolemund and Alex Hayes and Lionel Henry and Jim Hester and Max Kuhn and Thomas Lin Pedersen and Evan Miller and Stephan Milton Bache and Kirill Müller and Jeroen Ooms and David Robinson and Dana Paige Seidel and Vitalie Spinu and Kohske Takahashi and Davis Vaughan and Claus Wilke and Kara Woo and Hiroaki Yutani},
  year = {2019},
  journal = {Journal of Open Source Software},
  volume = {4},
  number = {43},
  pages = {1686},
  doi = {10.21105/joss.01686},
}

As a workaround, you can remove the bib file creation here, especially if you don't use it. https://github.com/rstudio/bookdown-demo/blob/5331ffcb5bc0ed3d86c8d94774f515080ff7dae4/index.Rmd#L32-L35

And otherwise, remove this citation (which is probably included due to one of the tidyverse package).

For a full fix, we need to know if R 4.2 fix the issue for you or not. Thanks !