0
> registerDoSNOW(makeCluster(4, type="SOCK")) Loading required package: methods Loading required package: DBI Loading required
> package: rJava Error: package or namespace load failed for ‘rJava’: 
> .onLoad failed in loadNamespace() for 'rJava', details:   call:
> dyn.load(file, DLLpath = DLLpath, ...)   error: unable to load shared
> object
> '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so':
> dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so,
> 6): Library not loaded: @rpath/libjvm.dylib   Referenced from:
> /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
> Reason: image not found Error: package ‘rJava’ could not be loaded
> Execution halted

This also happens if I try to use Knitr. So it is not related to registerDoSNOW() but to rJava and some kind of wrong pathing.

I've researched the common solutions (e.g., rJava load error in RStudio/R after "upgrading" to OSX Yosemite) to rJava not loading.

1) My Java is 64 bit version 2) library(rJava) loads fine 3) It's only when I try to use registerDoSNOW(makeCluster(4, type="SOCK"))

This only started happening after I upgraded to R 3.4.2 from 3.3. I upgraded because data.table complained that it could not make use of 64 bit architecture. When I upgraded, RStudio wouldn't run Java, which I fixed by executing sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

I tried the solutions here http://paulklemm.com/blog/2015-02-20-run-rjava-with-rstudio-under-osx-10-dot-10/ with no avail.

java version "1.8.0_101" Java(TM) SE Runtime Environment (build 1.8.0_101-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

1 Answer 1

1

I believe this process will solve your issue.

  1. install rJava from within a r terminal

  2. run ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

    • if the file already exists, overwrite it with sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
  3. run R CMD javareconf in a mac terminal session

Basically you're just setting up the java file that rJava needs and then reconfiguring R so it knows where to look.

If you get an error with something like /opt/X11/lib/* in it, then you need to install XQuartz, which can be found here.

1
  • R CMD javareconf for the win! Thank you! Commented Oct 26, 2017 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.