-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rJava "locks" on Java paths on load #334
Comments
By "touched" you mean loaded! The way packages work is to load their native code when the package is loaded (by design) so at that point it resolves the I was thinking about a re-write which would not link to |
Yes, I do mean loaded. But I also would like to stress this as "touched", because as I have demonstrated, the It would be great if you could defer the loading of JNI symbols to a later stage. I think this will improve the experience of users of |
I have added some rudimentary support in the feature/dynamic branch. This is only tested on macOS and Linux, unlikely to work on Windows at this point. But the nice thing is you can do (on macOS):
or
(thus proving that the actual JVM loading is done just before use). |
Apparently, I managed to install the feature/dynamic branch of In my opinion, it now works perfectly. Just what I wanted! Now I can even use I'm not sure I can test this on macOS or Windows, as this requires compilation, and on my Apple Silicon mac I could not figure out how to build |
You can't use Windows doesn't work right now (see https://github.com/s-u/rJava/actions) because I did not update the sources to build without linking JVM and I need to add the Java location detection from the build phase into the run-time - which will take some work. |
Yes, that I did figure out, and that's exactly what I did in a Linux container.
That I did not figure out, so I will try that to test on macOS, thank you for the hint! |
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 ranlibrary(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 likerJava::.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.
The text was updated successfully, but these errors were encountered: