From 5e1d2e6ed3ff498e91a772a1caef42359342bdc1 Mon Sep 17 00:00:00 2001 From: Tim Taylor Date: Wed, 27 Nov 2024 09:41:52 +0000 Subject: [PATCH] Use a more robust path for R This ensure that the version of R called matches the one you are in. Mainly relevant when you have multiple versions of R installed (e.g. R and R-devel) --- pkg/R/tinytest.R | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/R/tinytest.R b/pkg/R/tinytest.R index 266bfd9..019aa04 100644 --- a/pkg/R/tinytest.R +++ b/pkg/R/tinytest.R @@ -1132,7 +1132,13 @@ build_install_test <- function(pkgdir="./", testdir="tinytest" setwd(tdir) ## build package - system2("R", args=c("CMD", "build", "--no-build-vignettes", "--no-manual", shQuote(pkg))) + if(.Platform$OS.type == "windows") { + system2(file.path(R.home("bin"), "Rterm.exe") + , args=c("CMD", "build", "--no-build-vignettes", "--no-manual", shQuote(pkg))) + } else { + system2(file.path(R.home("bin"), "R") + , args=c("CMD", "build", "--no-build-vignettes", "--no-manual", shQuote(pkg))) + } ## find tar.gz and install in temporary folder. @@ -1198,7 +1204,11 @@ if (!is.null(cluster)) parallel::stopCluster(cluster) , encoding) write(scr, file="test.R") - system("Rscript test.R") + if(.Platform$OS.type == "windows") { + system2(file.path(R.home("bin"), "Rscript.exe"), args="test.R") + } else { + system2(file.path(R.home("bin"), "Rscript"), args="test.R") + } readRDS(file.path(tdir, "output.RDS"))