diff --git a/NAMESPACE b/NAMESPACE index 39bbdce..045e85d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -40,6 +40,7 @@ importFrom(prettyunits,pretty_sec) importFrom(rprojroot,find_package_root_file) importFrom(utils,head) importFrom(utils,tail) +importFrom(withr,local_path) importFrom(withr,with_dir) importFrom(withr,with_envvar) importFrom(xopen,xopen) diff --git a/NEWS.md b/NEWS.md index edcfe7e..908acb1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ # dev +* RStudio's Pandoc is now on the path during `rcmdcheck()` + and `rcmdcheck_process` (#109, #132, @dpprdan). + # 1.3.3 * `cran_check_results()` has now a `quiet` argument, and the download diff --git a/R/background.R b/R/background.R index b7bfcbe..cbcfa80 100644 --- a/R/background.R +++ b/R/background.R @@ -130,6 +130,12 @@ rcc_init <- function(self, private, super, path, args, build_args, cleanup <- FALSE } + # Add pandoc to the PATH for R CMD build. + # The updated PATH is also inherited in the subprocess below. + if (!nzchar(Sys.which("pandoc")) && nzchar(Sys.getenv("RSTUDIO_PANDOC"))) { + local_path(Sys.getenv("RSTUDIO_PANDOC")) + } + targz <- build_package(path, check_dir, build_args = build_args, libpath = libpath, quiet = TRUE) diff --git a/R/options.R b/R/options.R index c4bac9e..9d4ac95 100644 --- a/R/options.R +++ b/R/options.R @@ -43,6 +43,10 @@ #' fractional. Defaults to 1/3 of a second. The corresponding option is #' `rcmdcheck.timestamp_limit`. #' +#' * `RSTUDIO_PANDOC`: if set, rcmdcheck adds this environment variable +#' to the PATH if pandoc is not on the PATH already. It is usually set +#' in RStudio. +#' #' # Options #' #' * `rcmdcheck.num_colors`: the number of ANSI colors to use in the output. diff --git a/R/package.R b/R/package.R index 5424f93..12f8655 100644 --- a/R/package.R +++ b/R/package.R @@ -50,7 +50,7 @@ NULL #' #' @export #' @importFrom rprojroot find_package_root_file -#' @importFrom withr with_dir +#' @importFrom withr local_path with_dir #' @importFrom callr rcmd_safe #' @importFrom desc desc @@ -75,6 +75,11 @@ rcmdcheck <- function(path = ".", quiet = FALSE, args = character(), cleanup <- FALSE } + # Add pandoc to the PATH, for R CMD build and R CMD check + if (!nzchar(Sys.which("pandoc")) && nzchar(Sys.getenv("RSTUDIO_PANDOC"))) { + local_path(Sys.getenv("RSTUDIO_PANDOC")) + } + targz <- build_package(path, check_dir, build_args = build_args, libpath = libpath, quiet = quiet) diff --git a/man/rcmdcheck-config.Rd b/man/rcmdcheck-config.Rd index ddfbbe6..e2b9ba9 100644 --- a/man/rcmdcheck-config.Rd +++ b/man/rcmdcheck-config.Rd @@ -39,6 +39,9 @@ option is \code{rcmdcheck.num_colors}. rcmdcheck adds time stamps to the individual check steps. It may be fractional. Defaults to 1/3 of a second. The corresponding option is \code{rcmdcheck.timestamp_limit}. +\item \code{RSTUDIO_PANDOC}: if set, rcmdcheck adds this environment variable +to the PATH if pandoc is not on the PATH already. It is usually set +in RStudio. } }