r-lib / rcmdcheck

Run R CMD check from R and collect the results
https://rcmdcheck.r-lib.org
Other
115 stars 27 forks source link

Ability to ignore checks set by `--as-cran` #179

Closed jimhester closed 1 year ago

jimhester commented 2 years ago

Using args = '--as-cran' sets the environment variables during the check (https://github.com/wch/r-source/blob/722824a89bcc9bcd6848abcb80ce4f7f21246e1b/src/library/tools/R/check.R#L6430-L6510) so any variables set intools/check.env` are ignored.

This makes using tools/check.env less useful then it otherwise would be.

I don't know if there is anything the package could do to change this behavior, but possibly what it could provide is a way to set the equivalent of --as-cran in envvars, which then could be overriden.

Maybe based off of https://svn.r-project.org/R-dev-web/trunk/CRAN/QA/Kurt/.R/check_CRAN_regular.Renviron so it remains updated with at least some of the checks used on the check machines?

gaborcsardi commented 2 years ago

Those are not necessarily the same as --as-cran, though, and it is also only one cran machine. There is a good chance that we would be creating yet another check configuration, that is different than anything else.

I am also not sure if --as-cran only sets env vars. We might not be able to emulate exactly what it does via env vars only. But assuming that it only sets env vars, we could run a quick check for a very small package, record all R-related env vars, and then use them for the real check. So this would be always equivalent to --as-cran (in terms of env vars), but you could still tweak it.

jimhester commented 2 years ago

Most of what --as-cran does is here https://github.com/wch/r-source/blob/722824a89bcc9bcd6848abcb80ce4f7f21246e1b/src/library/tools/R/check.R#L6430-L6503, though there are a a few other places that explicitly check for the as_cran variable.

I agree there is no perfect solution, other than maybe doing post-check filtering of the outputs, which would be more complicated to implement and maintain.

Alternatively maybe we could convince R core to tweak that code to check for the existence of the envvar in all cases, rather than only in some like it does now.

gaborcsardi commented 1 year ago

It seems really hard to implement this in a way that works for all R versions, and in a way that we can keep current. So I am going to close it now. FWIW we now have the ability to ignore checks, that probably helps with the original problem.