This is a wrapper around callr::rcmd_safe()
that checks
that you have build tools available, and on Windows, automatically sets
the path to include Rtools.
Usage
rcmd_build_tools(..., env = character(), required = TRUE, quiet = FALSE)
Arguments
- ...
Parameters passed on to
rcmd_safe
.- env
Additional environment variables to set. The defaults from
callr::rcmd_safe_env()
are always set.- required
If
TRUE
, and build tools are not available, will throw an error. Otherwise will attempt to runcode
without them.- quiet
if
TRUE
suppresses output from this function.
Examples
# These env vars are always set
callr::rcmd_safe_env()
#> CYGWIN R_TESTS R_BROWSER
#> "nodosfilewarning" "" "false"
#> R_PDFVIEWER
#> "false"
if (has_build_tools()) {
rcmd_build_tools("CONFIG", "CC")$stdout
rcmd_build_tools("CC", "--version")$stdout
}
#> ── R CMD CONFIG ──────────────────────────────────────────────────────────
#> /opt/R/4.3.3/lib/R/bin/Rcmd: 64: exec: CONFIG: not found
#> ── R CMD CC ──────────────────────────────────────────────────────────────
#> /opt/R/4.3.3/lib/R/bin/Rcmd: 64: exec: CC: not found
#> [1] "/opt/R/4.3.3/lib/R/bin/Rcmd: 64: exec: CC: not found\n"