MacOS的rjava加载失败问题

MacOS的rjava加载失败问题

我的系统情况

RStudio Edition : Desktop
RStudio Version : v 1.1.383 (一直懒得更新)
OS Version : macOS 10.14 (18A391) (总是被迫更新)
R Version : 3.5.1 (2018-07-02)(现在可以更新到3.5.2了)

日常处理粉丝提问的时候,加载测试数据及代码

library(rJava)

很有趣的报错

> library(rJava)
arning: Error in : package or namespace load failed for ‘qdap’:
 .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.5/Resources/library/rJava/libs/rJava.so':
 dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/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.5/Resources/library/rJava/libs/rJava.so
 Reason: image not found

解决bug思路

轻轻松松就谷歌搜索到前辈的经历:https://github.com/rstudio/rstudio/issues/2254

很简单,按照最高票答案,在我的mac终端输入:sudo R CMD javareconf 代码即可,但是二次报错

trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
detected JNI linker flags : -L/Users/jmzeng/Library/Java/Extensions -L/Library/Java/Extensions -L/Network/Library/Java/Extensions -L/System/Library/Java/Extensions -L/usr/lib/java -L. -ljvm
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Unable to compile a JNI program

还是很明显,是xcrun问题,这个小毛病第十几次遇到了,每次更新macos系统都来一次,还是老规矩,使用代码;xcode-select --install 安装即可。

Comments are closed.