From 5dc2973457414c8a01af2cd782aba3d980853e73 Mon Sep 17 00:00:00 2001 From: mhermher Date: Thu, 12 Sep 2019 00:54:33 -0700 Subject: [PATCH] Set RHOME env-var to account for Rscript Rscript is not portable because it uses a compile time absolute path for the R home directory. So any R code that calls something like `system('/path/to/Rscript', ...)` will fail because the Rscript file will in turn call R at the original hard-coded absolute path. For example, parallel::newPSOCKnode() uses this type of command, meaning that any code using PSOCK parallel cluster will not work. I am not sure if shiny or any of this electron setup ever calls code that in turn makes a call to Rscript. If not, then it is probably fine. Interestingly, Rscript does check to see if the R home directory is being overridden in the environment, and uses that path instead of the compile time path. However, it does so by looking for the deprecated RHOME env-var instead of R_HOME. Instead of re-compiling Rscript (and wrangling with all the tooling involved in that), we can work around it by assigning into the RHOME env-var as well. --- R-Portable-Mac/bin/R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R-Portable-Mac/bin/R b/R-Portable-Mac/bin/R index 5dff7d0176..ec0fd1d8c7 100755 --- a/R-Portable-Mac/bin/R +++ b/R-Portable-Mac/bin/R @@ -58,6 +58,8 @@ export R_INCLUDE_DIR #R_DOC_DIR=/Library/Frameworks/R.framework/Resources/doc R_DOC_DIR=${R_HOME_DIR}/doc export R_DOC_DIR +RHOME="${R_HOME_DIR}" +export RHOME # Since this script can be called recursively, we allow R_ARCH to # be overridden from the environment.