Set RHOME env-var to account for Rscript #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I actually have not tested your library here, but I was reading through it because I was trying to create a portable R as well. I see that you have a binary Rscript in the root directory, so maybe this is a re-compiled version that works so maybe my change is not needed at all.
You can test it simply by
./R-Portable-Mac/bin/Rscript -e "R.home()"
and see if that is correctly set. Without this current fix, my attempt at portable R was giving me the compile time path rather than the ported path.