Skip to contents

R CMD INSTALL compiles the closures of a package to byte code. The R CMD INSTALL hook makes it use crbcc for this compilation. The hook is an R_PROFILE_USER file, which R reads at the start of each R process.

r_cmd_install_hook_path returns the path of the hook.

enable_r_cmd_install_hook sets the environment variable R_PROFILE_USER of this R session to the hook. The R processes that this R session starts read this variable. Thus install.packages() compiles the packages with crbcc. enable_r_cmd_install_hook(FALSE) sets R_PROFILE_USER back to its previous value.

Usage

r_cmd_install_hook_path()
enable_r_cmd_install_hook(enable = TRUE)

Arguments

enable

TRUE enables the hook. FALSE disables it.

Details

crbcc compiles only the packages that R installs from source. A binary package is already compiled. On Windows and with the R for macOS from CRAN, install.packages() installs binary packages by default. To install from source, use type = "source".

If crbcc cannot compile a closure, the hook compiles it with the compiler package.

When the hook is enabled, R does not read the usual .Rprofile file in the R processes that this R session starts.

Value

r_cmd_install_hook_path returns a path. enable_r_cmd_install_hook returns the previous state, TRUE or FALSE, invisibly.

Examples

r_cmd_install_hook_path()
#> [1] "/home/runner/work/_temp/Library/crbcc/r-cmd-install-hook.R"

if (FALSE) { # \dontrun{
enable_r_cmd_install_hook()
install.packages("MASS", type = "source")
enable_r_cmd_install_hook(FALSE)
} # }

## From a shell:
## R_PROFILE_USER=$(Rscript -e 'cat(crbcc::r_cmd_install_hook_path())') \
##   R CMD INSTALL foo_1.0.tar.gz