sparklyr : Error in validate_java_version_line(master, version) - r

R version 3.5.2 (2018-12-20) -- "Eggshell Igloo" Copyright (C) 2018
The R Foundation for Statistical Computing Platform:
x86_64-apple-darwin15.6.0 (64-bit)
After running these commands:
library(sparklyr)
sc <- spark_connect(master = "local")
I got this message:
* Using Spark: 2.4.0
Error in validate_java_version_line(master, version) :
Java version detected but couldn't parse version from: openjdk version "11.0.2" 2019-01-15
I've found this case https://github.com/rstudio/sparklyr/issues/1922
But not sure if there is something concrete I could do (and how) to overcome this blocked situation. Thanks in advance.

Install Java 8. You can install one from https://aws.amazon.com/corretto/ (select Coretto 8 for Java 8).
Go to terminal & run R with proper JAVA_HOME env variable set:
JAVA_HOME=`/usr/libexec/java_home -v 1.8` R
or if you want to launch RStudio:
JAVA_HOME=`/usr/libexec/java_home -v 1.8` open /Applications/RStudio.app

I met the exact same issue when upgrading JDK from 8 (on Ubuntu 16.04) to 11 (on Ubuntu 18.04). The chance is JDK 8 is still in your system, so you can downgrade easily with:
update-java-alternatives --list
sudo update-java-alternatives --set java-1.8.0-openjdk-amd64
Now sc <- spark_connect(master = "local") works.

Related

GnuTLS Error -50: Cannot install packages from Github in Rstudio?

The following lines prompt an error (which differs from this question):
library(devtools)
install_github("StatsWithR/statsr") # the same for any other open repos
The error is this:
Error: Failed to install 'unknown package' from GitHub:
Error -50 setting GnuTLS cipher list starting with +VERS-TLS1.3
Then I wanted to work around the problem caused by devtools, so I tried githubinstall, but the error became this:
Error in curl::curl_download(input, tmpFile, mode = "wb", quiet = !showProgress) :
Error -50 setting GnuTLS cipher list starting with +VERS-TLS1.3
It seems obvious that the issue is caused by GnuTLS and I found a similar thread: git/jenkins TLS issue, but I cannot find some hints there.
I also tried install_url, install_local, and install_git, but all failed.
Here is the information of the R I recently upgraded from 3.4.4(2018):
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 4
minor 1.2
year 2021
month 11
day 01
svn rev 81115
language R
version.string R version 4.1.2 (2021-11-01)
nickname Bird Hippie
I have been stuck with devtools and install_github. What can I try next?
I installed the r-base and Rstudio using apt install in an existing container, and the default settings(the default r version is 3.4.4) caused the issues I met, then I purged the r environment and created a new one in a new Docker container following this blog: Running RStudio Server with Docker.

Install mxnet package in Rstudio Cloud

I want to install the package mxnet on Rstudio Cloud, which is the cloud version of Rstudio. I tried it first with R 3.6, then R 3.5.3, neither worked.
I tried to install from with this piece of code:
cran <- getOption("repos")
cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/"
cran["dmlc"] <- "https://s3-us-west-2.amazonaws.com/apache-mxnet/R/CRAN/"
options(repos = cran)
install.packages("mxnet")
I got a 404 error file not found. Then i tried downloading the .tar.gz installation file associated with LInux/R/CPU, and it also gave an error:
ERROR: cannot extract package from
‘/cloud/project/apache-mxnet-src-1.5.0-incubating.tar.gz’
Here is my session info:
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS
Thanks for your help. I need to get this package installed and running on Rstudio Cloud.
RStudio Cloud is linux based
Platform: x86_64-pc-linux-gnu (64-bit)
The snippet you use is instruction for R on Windows CPU platform. R on Linux instruction there says to build it from source which wouldn't work on the cloud. Seems like no CRAN repo currently has binaries of the linux version of the mxnet package.
RStudio Cloud gives you access to the terminal and you can even download the sources for mxnet, but to build it you need sudo which the terminal doesn't provide so building from source stops on ./install_mxnet_ubuntu_r.sh command here:
git clone --recursive https://github.com/apache/incubator-mxnet.git mxnet
cd mxnet/docs/install
./install_mxnet_ubuntu_r.sh

jni.h file not found

I'm ultimately trying to install the RJDBC package on a mac running R 3.3.3 and Java 12 and Mojave OS.
When trying to install RDJBC I get the following error:
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.
If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.
So then I go ahead and run R CMD javareconf in the terminal and I get the following error:
conftest.c:1:10: fatal error: 'jni.h' file not found
I've found various questions online around the same topic and have tried out suggested solutions and none have worked for me. Ity could be a combination of my OS/Java version. Would someone be willing to walk me through a fix here?
Update:
Stacktrace
WARNING: Initial Java 12 release has broken JNI support and does NOT work. Use stable Java 11 (or watch for 12u if avaiable).
ERROR: Java exception occurred during rJava bootstrap - see stderr for Java stack trace.
Exception in thread "main" java.lang.NullPointerException
at java.base/jdk.internal.reflect.Reflection.verifyMemberAccess(Reflection.java:130)
at java.base/java.lang.reflect.AccessibleObject.slowVerifyAccess(AccessibleObject.java:673)
at java.base/java.lang.reflect.AccessibleObject.verifyAccess(AccessibleObject.java:666)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:638)
at java.base/java.lang.reflect.Field.checkAccess(Field.java:1075)
at java.base/java.lang.reflect.Field.get(Field.java:416)
Error in .jcheck(silent = FALSE) :
java.lang.NullPointerException.jcall(f, "Ljava/lang/Object;", "get", .jcast(ic, "java/lang/Object"))new("jobjRef", jobj = <pointer: 0x7fd4a04ac4b8>, jclass = "java/lang/NullPointerException")
Interestingly, it seems to work when I run R through terminal, but not in Rstudio.
This will need some tweaking. In general, R, Java and rJava are not quite easy things to setup when they are supposed to work together. Make sure to go through: http://www.owsiak.org/r-java-11-and-making-sure-you-can-load-rjava/
Note that due to changes in Java 12 it is no longer possible to dynamically affect location of shared libraries via reflection - this affects rJava. I am pretty sure you won't get rJava and any other JNI based codes working properly with Java 12 in R.
Once you have your R configured, it will work as expected
> R
R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)
...
...
> install.packages("RJDBC")
--- Please select a CRAN mirror for use in this session ---
...
> library(RJDBC)
Loading required package: DBI
>
Update
For Java 12 try following. Inside ~/.profile add following line
export JAVA_HOME=$(/usr/libexec/java_home -v 12)
then, run
> sudo R CMD javareconf \
JAVA_HOME=${JAVA_HOME} \
JAVA=${JAVA_HOME}/bin/java \
JAVAC=${JAVA_HOME}/bin/javac \
JAVAH=${JAVA_HOME}/bin/javah \
JAR=${JAVA_HOME}/bin/jar
and, inside R
> system("java -version")
java version "12.0.1" 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
> library(RJDBC)
Loading required package: DBI
Loading required package: rJava
>
Of course, you still need XCode.app as it contains headers for JNI.
Update
In order to make sure all the apps are getting Java 11 instead of Java 12 (not only CLI based) you can "disable" Java 12 following way.
cd /Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents
sudo mv Info.plist Info.plist~
Since now, even though you haven't removed Java 12, RStudio will pick up correct version.

Loading rJava on Mac OS High Sierra

I am trying to install rJava package for running the XLConnect package.
Here are my system details;
R studio:Version 1.0.153
Mac OS High Sierra Version 10.13.1 (17B1003)
R version: 3.4.2
jdk-9.0.1
however, i get the following error:
I have already followed the following threads on this topic but they don't work for me:
trouble installing and loading rJava on mac El Capitan
rJava does not run on macOS Sierra
rJava load error in RStudio/R after "upgrading" to OSX Yosemite
A push in the right direction will be greatly appreciated !!
I used the procedure at the following website:
https://github.com/MTFA/CohortEx/wiki/Run-rJava-with-RStudio-under-OSX-10.10,-10.11-(El-Capitan)-or-10.12-(Sierra)
The main steps are:
Install Apple Java 6
Install the newest Java from Oracle
Fix JAVA_HOME to point to the new version. Terminal command: sudo R CMD javareconf
Install rJava from source. Terminal command: unset JAVA_HOME; R --quiet -e 'install.packages("rJava", type="source", repos="http://cran.us.r-project.org")'
My environment is
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)
macOS High Sierra 10.13.2
I encountered this problem today and spent whole day trying to fix it. Luckily I found the solution at last. It works for me.
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
Note:
If the get ln: /usr/local/lib/libjvm.dylib: File exists
in terminal. Then you should delete this file and run the command above again.
This worked for me on an M1 Mac:
Download jdk-19_macos-x64_bin.tar.gz from Java
Unzip the file and move it to /Library/Java/JavaVirtualMachines/ (may need to sudo su first)
Set export JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk-19_macos-x64_bin/Contents/Home'
Run R CMD javareconf
#Kayle Sawyer's answer works almost perfectly, but you might need to reinstall command line tools first. Easiest way is to run the following in Terminal:
xcode-select --install
If you get an error saying command line tools are already installed, you can reinstall the package with this:
cd /Library/Developer/CommandLineTools/Packages/
open macOS_SDK_headers_for_macOS_10.14.pkg
You might need to update the second command based on your OS version.
Answers from https://github.com/frida/frida/issues/338

What version of R should I use to upgrade R in ubuntu 15.04

The codename (version name) of my ubuntu 15.04 is 'vivid'. But there is no such version is available in the CRAN.(Resource Location for R) What version should I install among available versions(they are precise, testy, xenial, yakety, and zesty) for ubuntu 15.04. The version of R I installed is (R version) 3.1.2 (2014-10-31) -- "Pumpkin Helmet".
versions of R for different versions of ubuntu are as given below.
Ubuntu 12.04: precise
Ubuntu 14.04: trusty
Ubuntu 16.04: xenial
I have got the answer from this wonderful video. I highly recommend to watch the video if you have to install and/or upgrade R.

Resources