-
Notifications
You must be signed in to change notification settings - Fork 79
Description
Hello @s-u ,
as you might remember, I made this companion package for R users to effortlessly install Java that matches their platform/cpu/etc and sets the JAVA environment variables in their current project/working dir and/or session ( https://github.com/e-kotov/rJavaEnv ).
One edge case I am struggling with, is when the user already has "touched" {rJava}
in ANY way. That is, if the user has only ran library(rJava)
, this triggers the .onLoad()
, after which point, even if the users has not touched .jinit()
, it is (seemingly) impossible to force {rJava}
to respect the JAVA_HOME that the user might be setting afterwards manually or with my package.
Even worse, though this is more of a side effect of R's and some IDE's autocomplete, as soon as the user types rJava::
in R console and presses tab, or if they have some R code in the R script that has direct references like rJava::.jinit
or any other function, that also triggers loading of {rJava}
namespace and apparently the .onLoad()
, and therefore also locks the paths where {rJava}
will look for Java...
This is a minor annoyance, but still an annoyance for the user. They have to restart the R session to be able to use any new JAVA_HOME path that they would want to apply after doing any even unintentional interaction with {rJava}
. I see room for improvement here.
Would you be able to not run parts of the .onLoad()
sequence that causes this "lock" on folders before the user actually does something more meaningful than just loading {rJava}
(intentionally or not)? I see a common use case where users list the libraries in the beginning of their R script. Hence, if they first list all packages they want to load, including {rJava}
, they essentially cannot change the JAVA_HOME anymore, as it will be ignored as soon as {rJava}
is loaded.
Alternatively, would it be possible to recheck the up-to-date JAVA_HOME environment variable (and any other relevant env vars) on the first run of .jinit()
or any other function in {rJava}
that actually triggers the initialisation of JVM?
This is related to the following issues:
#249 - essentially, the problem would be solved, if one could re-load {rJava}
after detaching, but we know that does not work.
#25 - somewhat related. What I am asking about here, is not re-loading the Java after initialisation, but rather to be able to change the Java path via JAVA_HOME before initialisation, which seems like a valid thing to be able do.