r-lib / devtools

Tools to make an R developer's life easier
https://devtools.r-lib.org
Other
2.39k stars 760 forks source link

`build_manual()` failure suppresses informative errors #2478

Open billdenney opened 1 year ago

billdenney commented 1 year ago

I have some invalid tex code in a manual (that I'm still trying to track down the exact error). When I tried to run build_manual(), it gives an error:

Error in `value[[3L]]()`:
! Failed to build manual

But, that gives no information on the actual error itself. When I go into the code for build_manual(), it appears to try to cat the e$stdtout, but on Windows, that is missing. The e$stderr appears to have all of the output.

https://github.com/r-lib/devtools/blob/aa3f88bc693d049e1b524ca1a86b300e2c954765/R/build-manual.R#L19

I think that the fix would either be to print(e) instead of cat(e$stdout) or perhaps it's an issue with callr::rcmd() in Windows not redirecting stderr to stdout correctly.

devtools::create(path = "foo")
#> ✔ Creating 'foo/'
#> ✔ Setting active project to 'C:/Users/wdenn/AppData/Local/Temp/RtmpOkKyEx/reprex-5e2414ea1ba0-bonny-fox/foo'
#> ✔ Creating 'R/'
#> ✔ Writing 'DESCRIPTION'
#> Package: foo
#> Title: What the Package Does (One Line, Title Case)
#> Version: 0.0.0.9000
#> Authors@R (parsed):
#>     * First Last <first.last@example.com> [aut, cre] (YOUR-ORCID-ID)
#> Description: What the package does (one paragraph).
#> License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a
#>     license
#> Encoding: UTF-8
#> Roxygen: list(markdown = TRUE)
#> RoxygenNote: 7.2.1
#> ✔ Writing 'NAMESPACE'
#> ✔ Setting active project to '<no active project>'
setwd("foo")
cat(file = "R/myfun.R",
"#' A function
#' \\deqn{w_i = \\frac{\\delta_{time,i-1,i} + \\delta_{time,i,i+1}}{2}}{w_i = (d_time[i-1,i] + d_time[i,i+1])/2}
#' \\deqn{\\delta_{time,i,i+1} = \\begin{cases}0 & i < 1 | i > K \\\\ t_{i+1} - t_i & otherwise\\end{cases}}{d_time = t_[i+1] - t_i, and zero if i < 1 or i > K}
#' @name myfun
NULL")
devtools::build_manual()
#> Error in `value[[3L]]()`:
#> ! Failed to build manual

#> Backtrace:
#>     ▆
#>  1. └─devtools::build_manual()
#>  2.   └─base::tryCatch(...)
#>  3.     └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>  4.       └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>  5.         └─value[[3L]](cond)
#>  6.           └─cli::cli_abort("Failed to build manual")
#>  7.             └─rlang::abort(...)

Created on 2022-10-15 with reprex v2.0.2

LukasWallrich commented 1 year ago

Just to add to the above: nothing about the error is displayed on Mac OS either - e$stderr is where the information lies.