Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

* `cran_check_results()` works again.

* `rcmdcheck()` now will print rcheck envvars ([#172](https://github.com/r-lib/rcmdcheck/issues/172))
Comment thread
tanho63 marked this conversation as resolved.
Outdated

# rcmdcheck 1.4.0

* `cran_check_results()` now downloads results in parallel, so it is
Expand Down
36 changes: 34 additions & 2 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,41 @@ do_check <- function(
}

# user supplied env vars take precedence
if (length(env)) chkenv[names(env)] <- env
if (length(env)) {
chkenv[names(env)] <- env
}

if (!quiet) {
cat_head("R CMD check")
Comment thread
tanho63 marked this conversation as resolved.
cat_line()
all_vars <- Sys.getenv()
rchk_vars <- all_vars[
grep("_R_CHECK|NOT_CRAN|RCMDCHECK|R_TESTS", names(all_vars))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could just print _R_CHECK var here — the idea is that devtools prints the env vars that it sets; rcmdcheck prints all the env vars that affect the operation of R CMD check, regardless of how they've been setting.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that it looked a little duplicative when called from devtools::check() and that we could let it all be handled by rcmdcheck? Here's what it looks like when you call devtools::check() with the PR rcmdcheck + release version devtools (note that it reprints the same variables, basically):

R> devtools::check("~/_nflverse/nflreadr")
══ Documenting ══════════════════════════════════════════════════════════════════════════════
ℹ Updating nflreadr documentation
ℹ Loading nflreadr

══ Building ═════════════════════════════════════════════════════════════════════════════════
Setting env vars:
• CFLAGS    : -Wall -pedantic -fdiagnostics-color=always
• CXXFLAGS  : -Wall -pedantic -fdiagnostics-color=always
• CXX11FLAGS: -Wall -pedantic -fdiagnostics-color=always
• CXX14FLAGS: -Wall -pedantic -fdiagnostics-color=always
• CXX17FLAGS: -Wall -pedantic -fdiagnostics-color=always
• CXX20FLAGS: -Wall -pedantic -fdiagnostics-color=always
── R CMD build ──────────────────────────────────────────────────────────────────────────────
✔  checking for file ‘/home/tan/_nflverse/nflreadr/DESCRIPTION’ ...
─  preparing ‘nflreadr’:
✔  checking DESCRIPTION meta-information ...
─  installing the package to build vignettes
✔  creating vignettes (7s)
─  checking for LF line-endings in source and make files and shell scripts (591ms)
─  checking for empty or unneeded directories
─  building ‘nflreadr_1.5.0.tar.gz’
   
══ Checking ═════════════════════════════════════════════════════════════════════════════════
Setting env vars:
• _R_CHECK_CRAN_INCOMING_USE_ASPELL_           : TRUE
• _R_CHECK_CRAN_INCOMING_REMOTE_               : FALSE
• _R_CHECK_CRAN_INCOMING_                      : FALSE
• _R_CHECK_FORCE_SUGGESTS_                     : FALSE
• _R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_: FALSE
• NOT_CRAN                                     : true
── R CMD check ──────────────────────────────────────────────────────────────────────────────

─ R CMD check env vars set:
• _R_CHECK_CRAN_INCOMING_                       = FALSE
• _R_CHECK_CRAN_INCOMING_REMOTE_                = FALSE
• _R_CHECK_CRAN_INCOMING_USE_ASPELL_            = TRUE
• _R_CHECK_FORCE_SUGGESTS_                      = FALSE
• _R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_ = FALSE
• NOT_CRAN                                      = true

My initial instinct was to make printing the envvars that relate to checking all get printed by rcmdcheck (even if set by devtools or otherwise), so also made a corresponding PR to remove the printing by devtools r-lib/devtools#2621

Copy link
Copy Markdown
Author

@tanho63 tanho63 Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as for the RCMDCHECK / R_TESTS grep patterns, I did a search through the rcmdcheck codebase for Sys.getenv https://github.com/search?q=repo%3Ar-lib%2Frcmdcheck%20Sys.getenv&type=code and saw those two patterns being referred to in a handful of places, figured they might as well get printed

Copy link
Copy Markdown
Author

@tanho63 tanho63 Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm happy to change to "just" the _R_CHECK ones if we have a stronger preference to have devtools print the vars set by devtools, just explaining the original rationale)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we had this, we'd drop the R_CHECK_ printing in devtools, but still set the other envvars.

rcmdcheck is used in other places apart from devtools, so the goals are a little different — here I'm worried more about env vars that are set elsewhere (i.e. not by devtools). We can also wait for Gabor to take a look.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we had this, we'd drop the R_CHECK_ printing in devtools, but still set the other envvars.

Yeah, I think that's what I tried to implement here (maybe worth eyeballing to confirm?) https://github.com/r-lib/devtools/pull/2621/files

]
rchk_vars[names(env)] <- env
Comment thread
tanho63 marked this conversation as resolved.
if (length(rchk_vars) == 0) {
cli::cat_bullet(
"No R CMD check env vars set",
col = "darkgrey",
bullet = "line",
bullet_col = "darkgrey"
)
}
if (length(rchk_vars) > 0) {
Comment thread
tanho63 marked this conversation as resolved.
cli::cat_bullet(
"R CMD check env vars set:",
col = "darkgrey",
bullet = "line",
bullet_col = "darkgrey"
)
cli::cat_bullet(
paste0(format(names(rchk_vars)), " = ", unname(rchk_vars)),
col = "darkgrey"
)
cat_line()
}
}

if (!quiet) cat_head("R CMD check")
callback <- if (!quiet) detect_callback(as_cran = "--as-cran" %in% args)
res <- rcmd_safe(
"check",
Expand Down
Loading