Closed e-kotov closed 4 months ago
Note: this is does NOT seem to be an issue if the system has some kind of Java already pre-installed using conventional methods. For example, there is no such problem in Rocker Geospatial image, as it already comes with Java 11.
when running in a Docker image (testing here with Binder https://github.com/e-kotov/r5r-containerized ) and also in macOS (see here https://github.com/ipeaGIT/r5r/issues/393 ), Java version is NOT recognized by setup_r5()
from {r5r}
or during the manual code execution of the internals of setup_r5()
. For example:
rJavaEnv::java_env_set(here::here("rjavaenv/linux/x64/21/"))
✔ Current R Session: JAVA_HOME and PATH set to /home/rstudio/rjavaenv/linux/x64/21/
✔ Current R Project/Working Directory: JAVA_HOME and PATH set to '/home/rstudio/rjavaenv/linux/x64/21/' in .Rprofile in '/home/rstudio/.Rprofile'
>
> rJavaEnv::java_check_version_rjava()
Using current session's JAVA_HOME: /home/rstudio/rjavaenv/linux/x64/21/
With the user-specified JAVA_HOME rJava and other rJava/Java-based packages will use Java version:
"21.0.3"
[1] TRUE
> Sys.getenv("JAVA_HOME")
[1] "/home/rstudio/rjavaenv/linux/x64/21/"
> rJava::.jinit()
> ver <- rJava::.jcall("java.lang.System", "S", "getProperty",
+ "java.version")
> ver
[1] "11.0.23"
Sort of solved, can be tested here https://github.com/e-kotov/r5r-containerized .
The issue is that R CMD javareconf
has to be executed with root privileges, which probably is a huge problem. Currently it is unclear which setups are affected and why. On regular macOS and Windows machines it does not seem to be an issue, but in Docker containers and one some macs (example problem here https://github.com/ipeaGIT/r5r/issues/393 ) - it is.
Performed tests on vanilla systems with no Java installed (#15) , and specifically on Windows and macOS with R packages installed from both source and binaries.
Based on these tests, I conclude that as long as user's setup allows to install {rJava}
from binaries and does not need to be build from source, {rJavaEnv}
performs well and does not require ANY previously installed Java on Windows or macOS. R CMD javareconf
(see #3) is also NOT needed. If the user wants, for whatever reason, to install {rJava}
from source, R CMD javareconf
is required.
On Linux (although further tests are required), Java does not need to be installed to be able to install {rJava}
from a repository that has pre-built binaries for Linux (such as Posit Package Manager), but even that will not help unless we instruct the user to do R CMD javareconf
.
So, Java does need to be installed (conventionally, but can also be installed with {rJavaEnv}
) before building {rJava}
from source (which makes sense). Otherwise, if {rJava}
is installed form pre-built binaries, no Java is required until the user tries to initialise Java from R using {rJava}
or {rJava}
-dependent package.
Consider the case when, say, a stock Rocker RStudio image is used. It has no Java. Or another clean system that does not have any version of any flavour of Java installed. In this case
{rJava}
may install, but will fail to load. See below.Therefore, if we install Java with:
We will get positive results for tools that call Java via command line:
But rJava-dependent packages will fail:
But
{rJava}
cannot be installed and loaded successfully even afterrJavaEnv::java_quick_install(21)
.So in that case, do we need to address the #3 with
rJavaEnv
?