The goal here is to install the dplyr-snowflakedb R
package on an AWS Linux machine. The problem is that the rJava
package will not install, it fails with the following error message:
“installation of package ‘rJava’ had non-zero exit status”
The dplyr.snowflakedb
package makes the following recommendations:
The rJava package needs to be installed and working with Java 8 to support the SnowflakeDB JDBC requirements. This may require:
installing Java 8
running R CMD javareconf so R uses the Java 8 for its JAVA_HOME
installing rJava from source so it can be linked against Java 8
Despite trying these strategies, rJava is still not able to be installed on AWS linux.
The AWS linux instance is running Java 8:
conda activate ~/anaconda3/envs/R
(R) [ec2-user@ip-xx-xx-xx-xx ~]$ java -version
>>> openjdk version "1.8.0_152-release"
>>> OpenJDK Runtime Environment (build 1.8.0_152-release-1056-b12)
>>> OpenJDK 64-Bit Server VM (build 25.152-b12, mixed mode)
The R CMD javareconf
command was executed:
Java interpreter : /home/ec2-user/anaconda3/envs/JupyterSystemEnv/jre/bin/java
Java version : 1.8.0_152-release
Java home path : /home/ec2-user/anaconda3/envs/JupyterSystemEnv
Java compiler : /home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/javac
Java headers gen.: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/javah
Java archive tool: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
detected JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
x86_64-conda_cos6-linux-gnu-cc -I"/home/ec2-user/anaconda3/envs/R/lib/R/include" -DNDEBUG -I/home/ec2-user/anaconda3/envs/JupyterSystemEnv/include -I/home/ec2-user/anaconda3/envs/JupyterSystemEnv/include/linux -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -I/home/ec2-user/anaconda3/envs/R/include -Wl,-rpath-link,/home/ec2-user/anaconda3/envs/R/lib -fpic -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -I/home/ec2-user/anaconda3/envs/R/include -fdebug-prefix-map=/tmp/build/80754af9/r-base_1570124924484/work=/usr/local/src/conda/r-base-3.6.1 -fdebug-prefix-map=/home/ec2-user/anaconda3/envs/R=/usr/local/src/conda-prefix -c conftest.c -o conftest.o
x86_64-conda_cos6-linux-gnu-cc -shared -L/home/ec2-user/anaconda3/envs/R/lib/R/lib -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/home/ec2-user/anaconda3/envs/R/lib -Wl,-rpath-link,/home/ec2-user/anaconda3/envs/R/lib -L/home/ec2-user/anaconda3/envs/R/lib -Wl,-rpath-link,/home/ec2-user/anaconda3/envs/R/lib -o conftest.so conftest.o -L/home/ec2-user/anaconda3/envs/JupyterSystemEnv/jre/lib/amd64/server -ljvm -L/home/ec2-user/anaconda3/envs/R/lib/R/lib -lR
JAVA_HOME : /home/ec2-user/anaconda3/envs/JupyterSystemEnv
Java library path: /home/ec2-user/anaconda3/envs/JupyterSystemEnv/jre/lib/amd64/server
JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
Updating Java configuration in /home/ec2-user/anaconda3/envs/R/lib/R
Done.
It is not clear how to install rJava
from source or Link it against Java 8.
This related question: Can't install rJava on ubuntu system advises to run the following command:
sudo apt-get install r-cran-rjava
however AWS Linux doesn't use apt-get
, it uses yum
, and the equivalent command with yum finds no package:
sudo yum install r-cran-rjava
>>> No package r-cran-rjava available.
Perhaps the issue is that JAVA_HOME is set to the JupyterSystemEnv
rather than the R
env?
rJava: Low-Level R to Java InterfaceCall and friends. Allows creation of objects, calling methods and accessing fields.
Make sure you install not only JRE, but JDK:
sudo yum install java-1.8.0-openjdk
sudo yum install java-1.8.0-openjdk-devel
sudo R CMD javareconf
install.packages("rJava")
install.packages(c("RJDBC", "DBI", "dplyr"))
install.packages("devtools")
devtools::install_github("snowflakedb/dplyr-snowflakedb")
If you have issues with install devtools try to instal dependencies or try another repo:
install.packages("devtools", dependencies=TRUE)
install.packages('devtools',dependencies=TRUE,
repos='https://stat.ethz.ch/CRAN/')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With