Open MichaelChirico opened 4 years ago
Some comment below on this PR ('RHOME' -> 'R_HOME') in case it helps move it forward. To me this one looks like a bug - possibly due to some legacy code. (Disclaimer: I don't know the history of 'RHOME' and 'R_HOME' and why there was two in the first place.)
PACKAGE INSTALLATION:
\item The deprecated environment variable \env{RHOME} is no longer
set when a package is installed: use \env{R_HOME} instead (and
depend on \code{R (>= 2.9)} ).
help("Rscript", package="utils") [src/library/utils/man/Rscript.Rd] mentions 'RHOME'; "Normally the version of R is determined at installation, but this can be overridden by setting the environment variable RHOME."
The relevant code that OP refers to in src/unix/Rscript.c is:
p = getenv("RHOME");
if(p && p) snprintf(cmd, PATH_MAX+1, "%s\%s\Rterm.exe", p, BINDIR); else { char rhome[MAX_PATH]; GetModuleFileName(NULL, rhome, MAX_PATH); p = strrchr(rhome,'\'); if(!p) {fprintf(stderr, "installation problem\n"); exit(1);} p = '\0'; snprintf(cmd, PATH_MAX+1, "%s\Rterm.exe", rhome); }
if(!(p && p)) p = rhome; / avoid snprintf here */ if(strlen(p) + 6 > PATH_MAX) { fprintf(stderr, "impossibly long path for RHOME\n"); exit(1); } snprintf(cmd, PATH_MAX+1, "%s/bin/R", p);
That's the only usage of env var 'RHOME' I can find in the code using
grep -F 'env("RHOME' -r --include="" grep -E 'env.RHOME' -r --include="*"
PS. There's a comment in src/library/methods/R/SClasses.R reading "## see $RHOME/src/main/duplicate.c for the corresponding datatypes". Maybe that should be updated to use '$R_HOME/...' or just 'RHOME/...'?
NA
Rscript.c gets the r home path (runtime) by using the command
getenv("RHOME")
where I believe it should be usinggetenv("R_HOME")
with the underscore. From poking around in the docs, it seems like RHOME is some older deprecated version of R_HOME.This is line 200 of Rscript.c. It would just be a 1 character change, but I don't have SVN set up and don't really know how to use it.
This is only an issue when R_HOME is over-ridden in R, and some code ends up calling something like `system('...Rscript', ...). That Rscript system call will not respect the over-ridden R home with which that R session was started.
METADATA