Loading rJava on Mac OS High Sierra - r

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

Related

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

sparklyr : Error in validate_java_version_line(master, version)

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.

R packages failed to install: x86_64-apple-darwin13.4.0-ar: No such file or directory - What is "ar"?

I go this error when installing R packages like RStan (and anything that depends on it such as brms) and Devtools. Since in the message displayed during the installation, everything before this look normal, I think the failure to install can be boiled down to this:
/Users/lambda/anaconda3/bin/x86_64-apple-darwin13.4.0-ar -rs ../lib/libStanHeaders.a cvodes/src/cvodes/cvodes.o cvodes/src/cvodes/cvodes_io.o cvodes/src/cvodes/cvodea.o cvodes/src/cvodes/cvodea_io.o cvodes/src/cvodes/cvodes_direct.o cvodes/src/cvodes/cvodes_band.o cvodes/src/cvodes/cvodes_dense.o cvodes/src/cvodes/cvodes_diag.o cvodes/src/cvodes/cvodes_spils.o cvodes/src/cvodes/cvodes_spbcgs.o cvodes/src/cvodes/cvodes_spgmr.o cvodes/src/cvodes/cvodes_sptfqmr.o cvodes/src/cvodes/cvodes_sparse.o cvodes/src/cvodes/cvodes_bandpre.o cvodes/src/cvodes/cvodes_bbdpre.o cvodes/src/sundials/sundials_band.o cvodes/src/sundials/sundials_direct.o cvodes/src/sundials/sundials_math.o cvodes/src/sundials/sundials_pcg.o cvodes/src/sundials/sundials_spbcgs.o cvodes/src/sundials/sundials_spgmr.o cvodes/src/sundials/sundials_dense.o cvodes/src/sundials/sundials_iterative.o cvodes/src/sundials/sundials_nvector.o cvodes/src/sundials/sundials_sparse.o cvodes/src/sundials/sundials_spfgmr.o cvodes/src/sundials/sundials_sptfqmr.o cvodes/src/nvec_ser/nvector_serial.o
make: /Users/lambda/anaconda3/bin/x86_64-apple-darwin13.4.0-ar: No such file or directory
make: *** [static] Error 1
ERROR: compilation failed for package ‘StanHeaders’
I got this same error both with Xcode compiler and clang4 compiler; I don't think the problem is with the compiler, but with the thing called ar. BTW, I have installed Rcpp and it works. I have seen others having the same problem when installing RPy2. So what is that ar thing and how to fix it?
R version:
> version
_
platform x86_64-apple-darwin13.4.0
arch x86_64
os darwin13.4.0
system x86_64, darwin13.4.0
status
major 3
minor 4.2
year 2017
month 09
day 28
svn rev 73368
language R
version.string R version 3.4.2 (2017-09-28)
nickname Short Summer
I just faced the same problem and I am using anaconda's Rstudio.
My way to fixed it is to install it in terminal, first to try these two on your terminal.
>conda install -c mittner r-rstan
>conda install -c r r-stanheaders #to install the packages in terminal
although I'm not sure where was wrong but it did work fine on me.
hope it helps.
// In the end it seems that there's something wrong with my Anaconda-Navigator, I reinstalled a RStudio and it goes fine.
I had the same problem with Rstudio from anaconda3. Then I from the anaconda navigator (Environments) I installed the gfortran_osx-64 package.
This got me the x86_64-apple-darwin15.5.0-gfortran binary under /anaconda3/bin.
Making a symbolic link did the trick:
elisa#~>ln -s /anaconda3/bin/x86_64-apple-darwin13.4.0-gfortran /anaconda3/bin/x86_64-apple-darwin1
I already solved this problem. I got this problem when using RStudio inside Anaconda. Later I installed R 3.4.3 and RStudio outside Anaconda and everything went smoothly. It might have been some problem with the Anaconda RStudio.

Problems compiling rJava with RStudio on macOS Sierra 10.12.6

I am trying to install the rJava package into Rstudio using these instructions:
https://github.com/MTFA/CohortEx/wiki/Run-rJava-with-RStudio-under-OSX-10.10,-10.11-(El-Capitan)-or-10.12-(Sierra)
However, when I run this command:
unset JAVA_HOME R --quiet -e 'install.packages("rJava", type="source", repos="http://cran.us.r-project.org")'
I am getting this error:
clang: error: unsupported option '-fopenmp'
Any workarounds or suggestions?
Take a look here. Lots depends on R version. It might be that you need to recompile rJava
R 3.4, rJava, macOS and even more mess ;)
R, Java, rJava and macOS adventures
You need compiler with OpenMP support - thus, you need to use different clang version comparing to what you get out of the box.

Cannot run R from terminal after upgrading to macOS Sierra

I recently updated my macbook to macOS Sierra (Version 10.12.3 (16D32)), and I am no longer able to run R directly from Terminal:
DN51ssqi:~ kjytay$ R
-bash: R: command not found
DN51ssqi:~ kjytay$ R --version
-bash: R: command not found
Opening R from the Applications folder or from RStudio works fine. Anyone experience this issue/has been able to fix it?
Here is my R version information:
platform x86_64-apple-darwin13.4.0
arch x86_64
os darwin13.4.0
system x86_64, darwin13.4.0
status
major 3
minor 3.2
year 2016
month 10
day 31
svn rev 71607
language R
version.string R version 3.3.2 (2016-10-31)
nickname Sincere Pumpkin Patch
This is just a guess, but I'm thinking this is probably an issue with your PATH settings, which might have been overwritten when you upgraded*. Seems worth a try at least. This is from the RStudio support pages**:
R from source (including MacPorts and Homebrew)
When R is installed from CRAN on OS X the R executable is installed at
/usr/bin/R. However, if R is installed directly from source or via a
package manager like MacPorts or Homebrew, then the R executable is
installed to either /usr/local/bin/R (Homebrew) or /opt/local/bin/R
(MacPorts). In order to support these variations, RStudio scans for
the R executable in the following sequence:
/usr/bin/R
/usr/local/bin/R
/opt/local/bin/R
If RStudio is not able to locate R by scanning these locations, it
will fall back to using whatever version of R is located at
/Library/Frameworks/R.framework/.
If RStudio is finding R OK, then you must have it at one of these locations. Make sure these locations are in your $PATH list:
In the Terminal:
echo $PATH
Will display your current PATHs list. If any of the locations in the RStudio quote are missing, you can see if that's where R is located by trying to specify that location. For example:
/usr/local/bin/R
If that works to start R, just add that location to your PATHs list:
export PATH=$PATH:/usr/local/bin
So that OSX knows where to find it!
* It's been noted elsewhere that homebrew breaks, for example, on upgrade to Sierra. Here's a blog post outlining some steps an R user might like to take after the upgrade: http://www.statsblogs.com/2017/01/26/upgrading-to-macos-sierra-nee-osx-for-r-users/
** Here's the support page where the quote is from https://support.rstudio.com/hc/en-us/articles/200486138-Using-Different-Versions-of-R

Resources