-
-
Notifications
You must be signed in to change notification settings - Fork 878
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
catch error=TRUE chunks produced by hook_purl() #2338
Comments
This bug makes all packages that have a vignette with an The problem is covered up by the fact that checking packages with |
Sorry for the trouble. This change was intentional (see changelog), and CRAN made the request for change, after they changed It can be difficult to deal with these BTW, you can also set the chunk option |
Correction: For R < 4.4.0, this env var has to be set (or use |
To clarify, I see this issue more as a wishlist item than a bug in knitr. A simpler solution for
Yes, knitr has long offered several options for the vignette author to deal with these problems on a case-by-case basis. I've used |
Yes, that's the problem. The differentiation is only possible for Lines 586 to 587 in f1788b8
but not possible for Line 135 in f1788b8
so I'm afraid that |
hi, data.table is also having this issue Rdatatable/data.table#6220 |
i meant |
I am getting new ERRORs on CRAN now too from a chunk with |
@tdhock Yes, for R < 4.4.0, you need to use @Enchufa2 In case I didn't make it clear enough above, R sets |
@yihui There's something I don't quite understand or I see contradicting messages here. Please, correct me if I'm wrong, but:
Therefore, with the most recent version of knitr,
Yet I see failures on CRAN for |
@Enchufa2 Your understanding is mostly correct, but I don't think CRAN uses
but it's absent in CRAN's check log, e.g., https://www.r-project.org/nosvn/R.check/r-oldrel-macos-arm64/simmer-00check.html |
CRAN has recently changed the value of |
It happens also for other package: https://cran.r-project.org/web/checks/check_results_clock.html |
I have contacted Simon to set For package authors who do not use the |
Now code chunks marked with |
Thanks. I can confirm that now (47267f5, implementing your ## ----test, error=TRUE---------------------------------------------------------
try({
1 + ""
}) Using
without terminating R, but wrapped in
|
When a chunk is evaluated under
error=TRUE
, knitr catches errors as the code is declared to fail. Thehook_purl()
-produced R script, however, does not currently account for that.Here is a minimal example (inspired by
tests/testit/knit-handlers.Rmd
):Using current knitr 1.46, this produces the following R script (
knit-error.R
):Running that script fails, of course:
I think knitr could take advantage of the new R option "catch.script.errors" introduced in R 4.4.0. For example, for the above test chunk (with a local
error=TRUE
setting), I could imaginehook_purl()
producingThis would enable testing R scripts from vignettes that are shipped with packages (in
inst/doc
) even if they useerror=TRUE
chunks.On a related note,
eval=FALSE
code chunks don't have this problem ashook_purl()
already takes care of commenting such code:knitr/R/hooks-extra.R
Line 150 in 44a7bee
The text was updated successfully, but these errors were encountered: