Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rJava load failed in R/Rstudio after upgrading to OSX Catalina [duplicate]

I recently upgraded OSX from Mojave to Catalina. After the upgrade I couldn't run JGR() package in Rstudio because rJava could not be loaded. I repeatedly get the error:

    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.6/Resources/library/rJava/libs/rJava.so':
      dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/r        .Java/libs/rJava.so, 6): Library not loaded:         /Library/Java/JavaVirtualMachines/jdk-        11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
      Referenced from:         /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/li        .bs/rJava.so
      Reason: image not found
    Error: package ‘rJava’ could not be loaded

Last time I had this problem (in OSX Mojave) I installed all packages using "install.packages("data", type = "binary"), however this doesn't solve the problem this time.

Can anyone help me and fix this problem? Any solutions how to proceed?

like image 467
DaLu Avatar asked Oct 08 '19 08:10

DaLu


2 Answers

Same problem with me after update Catalina. I tried many methods posted online, while none of them works.

According to the error message, it seems that Rstudio under Catalina could only run JDK11.0.1. So I uninstalled my JDK13.0.4 and then install the old version JDK11.0.1, and it works for me.

Maybe you can try install JDK11.0.1.

like image 137
joshua zhu Avatar answered Nov 16 '22 02:11

joshua zhu


I had the same problem after upgrading from Mojave to Catalina. Long story short, this is the only solution that worked for me:

In the terminal, use the following command

install_name_tool -change /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib \
    /Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home/jre/lib/server/libjvm.dylib \
    /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so
like image 2
Dan88 Avatar answered Nov 16 '22 02:11

Dan88