Skip to content
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

Should purl() wrap try({}) blocks around error=true chunks ? #2368

Open
jeroen opened this issue Oct 8, 2024 · 1 comment
Open

Should purl() wrap try({}) blocks around error=true chunks ? #2368

jeroen opened this issue Oct 8, 2024 · 1 comment

Comments

@jeroen
Copy link

jeroen commented Oct 8, 2024

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:

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.

@jeroen jeroen changed the title Should purl() wrap error=true blocks in try() Should purl() wrap error=true chunks in a try({}) block Oct 8, 2024
@jeroen jeroen changed the title Should purl() wrap error=true chunks in a try({}) block Should purl() wrap try({}) blocks around error=true chunks ? Oct 8, 2024
@yihui
Copy link
Owner

yihui commented Oct 8, 2024

Yes, I think that's a good idea. Will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants