knitr
knitr copied to clipboard
Should purl() wrap `try({})` blocks around `error=true` chunks ?
Running R CMD check --no-build-vignettes
on a package which has a vignette with a '''{r error=TRUE}
block results in a check error because R script that was purl'ed from the vignette, does not account for the error=TRUE
.
For example, if we check the V8 package with --no-build-vignettes
I get:
R CMD check --no-build-vignettes V8_5.0.1.tar.gz
# ....
# * checking package vignettes ... OK
# * checking running R code from vignettes ...
# ‘npm.Rmd’ using ‘UTF-8’... OK
# ‘v8_intro.Rmd’ using ‘UTF-8’... failed
# ERROR
Because CRAN now published the purled script on the site, we can easily see the problem:
- https://cran.r-project.org/web/packages/V8/vignettes/npm.Rmd
- https://cran.r-project.org/web/packages/V8/vignettes/v8_intro.R
<-- purled script by cran
Note that the Rmd contains several eval=FALSE
and error=TRUE
chunks. The eval=FALSE
chunks are commented out in the output script, which makes sense. However the error=TRUE
chunk is run as-is, and hence script errors.
I think the chunk that contains error=TRUE
should be wrapped in try({....})
in the purled script. The default behavior of try is silent=FALSE
so it results in the identical behavior as when building the vignette: display the error and proceed.