-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failure to build chapter doesn't immediately stop book from building #920
Comments
Just to give you a sense of how annoying this is. Here's a link to a ~3,000 line log file I need to scroll through to figure out why the book failed to build: https://gist.github.com/hadley/04f96d091364fdd198031e078cdb1b1e |
When I try to compile the mastering shiny book, I encounter some errors and it stops the rendering process at If I try with bookdown demo book by introducing an error in 02-literature.Rmd for example, it will stop the rendering of the book at this chapter without processing any further. So it seems it is not something generic about bookdown, and could be specific to a setup. I was wondering if this was interactive vs non-interactive but running Rscript.exe -e "bookdown::render_book('index.Rmd', 'bookdown::gitbook')" in terminal also throws the error at the chapter rendering, and do not build the whole book. Did I miss anything ? Is this is happening for you no matter the book ? |
I normally run the book via RStudio, which generates
I have the same problem with R4DS. |
I can't reproduce this unfortunatly - I tried on Windows and on Ubuntu with the Mastering Shiny book by cloning the repo. Everytime I have an error within one the file, it stops the rendering at that file. I tried with Steps I did
```{r}
stop('Creating an error to test issue #920')
```
here is the whole result I got in the console > rmarkdown::render_site(output_format = 'bookdown::pdf_book', encoding = 'UTF-8')
processing file: index.Rmd
|......................................................................| 100%
inline R code fragments
output file: index.knit.md
processing file: introduction.Rmd
|.... | 6%
ordinary text without R code
|........ | 11%
label: unnamed-chunk-1 (with options)
List of 1
$ include: logi FALSE
|............ | 17%
ordinary text without R code
|................ | 22%
label: unnamed-chunk-2
Quitting from lines 10-11 (introduction.Rmd)
Error in eval(expr, envir, enclos) : Creating an error to test issue #920
Calls: local ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution halted
Error in Rscript_render(f, render_args, render_meta, add1, add2) :
Failed to compile introduction.Rmd Unfortunatly, without being able to reproduce, I will have a hard time looking further - I wonder why I don't encounter this behavior if you have it in two books. I have this packageVersion("bookdown")
#> [1] '0.21'
packageVersion("rmarkdown")
#> [1] '2.4.6'
packageVersion("knitr")
#> [1] '1.30' Do you have special config regarding error in a Rprofile or else ? Could we try to reproduce this in an example using the bookdown-demo example that is simple book ? That may be easier to isolate the issue. |
That was useful, thanks! It also failed for me when run with options(error = rlang::entrace) I use this to give better tracebacks for base errors, so it would be nice to figure out why this breaks knitr. I'm happy to look into it if you can point me to the code responsible for generating the "Execution halted" error. |
I wonder if the root cause is using |
Thanks, I'll investigate further with that option activated. I'll get back to you. |
Regarding the Execution halted, I believe this comes from R here: Bookdown call > traceback()
8: stop("Failed to compile ", file)
7: Rscript_render(f, render_args, render_meta, add1, add2)
6: render_new_session(files, main, config, output_format, clean,
envir, ...)
5: render_book("index.Rmd", output_format = output_format, envir = envir)
4: render_book_script(output_format, envir, quiet)
3: in_dir(input, render_book_script(output_format, envir, quiet))
2: generator$render(input_file = input_file, output_format = output_format,
envir = envir, quiet = quiet)
1: rmarkdown::render_site(output_format = "bookdown::pdf_book",
encoding = "UTF-8") That would mean the use of Could this be the source of the error ? |
It is indeed a |
I can now reproduce by using I think we narrowed down the issue now. @hadley you know better |
And here is the reprex of the underlying issue in bookdown res <- xfun::Rscript(
shQuote(c("--vanilla", "-e", 'stop("An error")'))
)
res
#> [1] 1
res <- xfun::Rscript(
shQuote(c("--vanilla", "-e", 'options(error = rlang::entrace); stop("An error")'))
)
res
#> [1] 0 Created on 2020-10-19 by the reprex package (v0.3.0.9001) First case throws 1 as a result, hence bookdown knows there is an error. Second throws 0 as a result, so bookdown does not know there is an error. |
Last precision: this is not an issue with only temp_r <- tempfile()
xfun::write_utf8(c('stop("An error")'), temp_r)
# will error
res <- callr::rscript(temp_r, "--vanilla")
#> Error: An error
#> Execution halted
#> Error in (function (command = NULL, args = character(), error_on_status = TRUE, : System command 'Rscript' failed, exit status: 1, stdout & stderr were printed
# res was not created
res
#> Error in eval(expr, envir, enclos): object 'res' not found
temp_r <- tempfile()
xfun::write_utf8(c('options(error = rlang::entrace)', 'stop("An error")'), temp_r)
# will not error on our console
res <- callr::rscript(temp_r, "--vanilla")
#> Error: An error
str(res)
#> List of 5
#> $ status : int 0
#> $ stdout : chr ""
#> $ stderr : chr "Error: An error\n"
#> $ timeout: logi FALSE
#> $ command: chr [1:3] "/usr/lib/R/bin/Rscript" "/tmp/RtmpV57zmp/file24f25c9e5c96" "--vanilla" Created on 2020-10-19 by the reprex package (v0.3.0.9001) First case without |
Same in terminal also in Ubuntu $ /usr/lib/R/bin/Rscript --vanilla -e "stop('An error')"
Error: An error
Execution halted
$ /usr/lib/R/bin/Rscript --vanilla -e "options(error = rlang::entrace);stop('An error')"
Error: An error |
Yeah, it's ok with callr::r(function() {
options(error = rlang::entrace)
stop("Hi!")
})
#> Error: callr subprocess failed: Hi! Created on 2020-10-19 by the reprex package (v0.3.0.9001) I'll figure out what's going on on the |
(If you run |
Oh I did not know that. That is insteresting ! It is clearly useful for debugging. Thanks for sharing. |
* Preserve exit status when `entrace()` is used as handler Fixes rstudio/bookdown#920 Closes #1052 * Fix error status in covr ``` out$status not equal to 1L. 1/1 mismatches [1] 124 - 1 == 123 ``` * `system2()` does not have a `timeout` argument in R < 3.5 * Skip test on R < 3.3
Unlike calling handlers,
|
# rlang 0.4.9 ## Breaking changes * Dropped support for the R 3.2 series. ## New features * `inject()` evaluates its argument with `!!`, `!!!`, and `{{` support. * New `enquo0()` and `enquos0()` operators for defusing function arguments without automatic injection (unquotation). * `format_error_bullets()` is no longer experimental. The `message` arguments of `abort()`, `warn()`, and `inform()` are automatically passed to that function to make it easy to create messages with regular, info, and error bullets. See `?format_error_bullets` for more information. * New `zap_srcref()` function to recursively remove source references from functions and calls. * A new compat file for the zeallot operator `%<-%` is now available in the rlang repository. * New `%<~%` operator to define a variable lazily. * New `env_browse()` and `env_is_browsed()` functions. `env_browse()` is equivalent to evaluating `browser()` within an environment. It sets the environment to be persistently browsable (or unsets it if `value = FALSE` is supplied). * Functions created from quosures with `as_function()` now print in a more user friendly way. * New `rlang_print_backtrace` C callable for debugging from C interpreters (#1059). ## Bugfixes and improvements * The `.data` pronoun no longer skips functions (#1061). This solves a dplyr issue involving rowwise data frames and list-columns of functions (tidyverse/dplyr#5608). * `as_data_mask()` now intialises environments of the correct size to improve efficiency (#1048). * `eval_bare()`, `eval_tidy()` (#961), and `with_handlers()` (#518) now propagate visibility. * `cnd_signal()` now ignores `NULL` inputs. * Fixed bug that prevented splicing a named empty vector with the `!!!` operator (#1045). * The exit status of is now preserved in non-interactive sessions when `entrace()` is used as an `options(error = )` handler (#1052, rstudio/bookdown#920). * `next` and `break` are now properly deparsed as nullary operators. # rlang 0.4.8 * Backtraces now include native stacks (e.g. from C code) when the [winch](https://r-prof.github.io/winch/) package is installed and `rlang_trace_use_winch` is set to `TRUE` (@krlmlr). * Compatibility with upcoming testthat 3 and magrittr 2 releases. * `get_env()` now returns the proper environment with primitive functions, i.e. the base namespace rather than the base environment (r-lib/downlit#32). * `entrace()` no longer handles non-rlang errors that carry a backtrace. This improves compatibility with packages like callr. * Backtraces of unhandled errors are now displayed without truncation in non-interactive sessions (#856). * `is_interactive()` no longer consults "rstudio.notebook.executing" option (#1031).
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. |
Instead, it fails later when assembling the entire book. For example, in Mastering Shiny if the
scaling-test.Rmd
chapter has an error, the build process completes but gives a less informative error:And then to find the source of the error I have to scroll up through a very large amount of output to find:
It would be better to fail earlier.
The text was updated successfully, but these errors were encountered: