question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to load rcdk because of rJava

See original GitHub issue
r$> library(rcdk)                                                                                                       
Loading required package: rcdklibs
Loading required package: rJava
Error: package or namespace load failed for ‘rJava’:
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: dyn.load(jli, FALSE)
  error: unable to load shared object '/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/lib/jli/libjli.dylib':
  dlopen(/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/lib/jli/libjli.dylib, 10): no suitable image found.  Did find:
        /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/lib/jli/libjli.dylib: mach-o, but wrong architecture
        /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/lib/jli/libjli.dylib: mach-o, but wrong architecture
Error: package ‘rJava’ could not be loaded

I came across this similar thread therefore I tried sudo R CMD javareconf but it does not work for me.

chrislam@ChrisLams-MBP MVA_DNF % sudo R CMD javareconf
Password:
Java interpreter : /usr/bin/java
Java version     : 11.0.10
Java home path   : /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar

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$(JAVA_HOME)/lib/server -ljvm
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/include/darwin  -I/opt/R/arm64/include   -fPIC  -falign-functions=64 -Wall -g -O2  -c conftest.c -o conftest.o
clang -arch arm64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: ignoring file /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/lib/server/libjvm.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64


JAVA_HOME        : /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.

the following is my Sys.info() and my radian details

r$> Sys.info()                                                                                                                           
                                                                                               sysname 
                                                                                              "Darwin" 
                                                                                               release 
                                                                                              "20.3.0" 
                                                                                               version 
"Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101" 
                                                                                              nodename 
                                                                                  "ChrisLams-MBP.home" 
                                                                                               machine 
                                                                                               "arm64" 
                                                                                                 login 
                                                                                                "root" 
                                                                                                  user 
                                                                                            "chrislam" 
                                                                                        effective_user 
                                                                                            "chrislam"
chrislam@ChrisLams-MBP MVA_DNF % radian
R version 4.1.0 (2021-05-18) -- "Camp Pontanezen"
Platform: aarch64-apple-darwin20 (64-bit)`
chrislam@ChrisLams-MBP ~ % java -version
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
psobolewskiPhDcommented, Jun 30, 2021

Yeah this line in the error /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/lib/jli/libjli.dylib: mach-o, but wrong architecture Means you have mixed architectures. On Apple Silicon all components need to be either x86, so the whole kit and caboodle is emulated via Rosetta or all arm64 so everything is native. Looks like your R is native (arm64), meanwhile AdoptOpenJDK does not yet have a native JDK/JRE. You can install a native one from homebrew: https://formulae.brew.sh/formula/openjdk#default Or from Azul: https://www.azul.com/downloads/?os=macos&architecture=arm-64-bit You may need to install the package from source, but I think most if not all CRAN packages are now arm64 aware.

If you need to use Adopt specifically, download x86 R and use that with your AdoptOpenJDK (with a speed penalty).

0reactions
fdq09ecacommented, Jun 30, 2021
> install.packages(rcdk, type"source")
Error: unexpected string constant in "install.packages(rcdk, type"source""
> install.packages(rcdk, type="source")
Error in install.packages(rcdk, type = "source") : 
  object 'rcdk' not found
> install.package(rcdk, type="source")
Error in install.package(rcdk, type = "source") : 
  could not find function "install.package"
> install.packages("rcdk", type="source")
trying URL 'https://cran.ma.imperial.ac.uk/src/contrib/rcdk_3.5.0.tar.gz'
Content type 'application/x-gzip' length 270214 bytes (263 KB)
==================================================
downloaded 263 KB

* installing *source* package ‘rcdk’ ...
** package ‘rcdk’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
sh: line 1: 42816 Trace/BPT trap: 5       R_TESTS= '/Library/Frameworks/R.framework/Resources/bin/R' --no-save --no-restore --no-echo 2>&1 < '/var/folders/t6/qy2rcbdx0g9_fv98q1g48v_h0000gn/T//RtmpxRdKiW/filea73973abd4a4'
ERROR: lazy loading failed for package ‘rcdk’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/rcdk’

The downloaded source packages are in
	‘/private/var/folders/t6/qy2rcbdx0g9_fv98q1g48v_h0000gn/T/RtmpRx3rbx/downloaded_packages’
Warning message:
In install.packages("rcdk", type = "source") :
  installation of package ‘rcdk’ had non-zero exit status

seems it does not work, I tried their to install by devtools as suggested by CDK-R repo

library(devtools)
install_github("https://github.com/CDK-R/rcdklibs")
install_github("https://github.com/CDK-R/cdkr", subdir="rcdk")

but still not success. I think the most problematic is the dependence rcdklibs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rcellminer failing to load because of rcdk
Setenv() but to no avail. My current system java is : openjdk version "1.8.0_92". OpenJDK Runtime Environment (Zulu 8.15.0.1-macosx) (build 1.8 ...
Read more >
Problems when trying to load a package in R due to rJava
Its because either one of the Java versions(32 bit/64 bit) is missing from your computer. Try installing both the Jdks and run the...
Read more >
Using the CDK from R
The CDK is a Java library for cheminformatics that supports a wide ... However, since it loads all the molecules from the specified...
Read more >
error: JAVA_HOME cannot be determined from the Registry
After installing and loading the xlsx package, the error “JAVA HOME cannot be found from the Registry” was returned to the R interface....
Read more >
bunk@debian.org: Bug#982111: r-cran-rcdk: autopkgtest failure
Loading required package: rcdklibs. Loading required package: rJava. Error: package or namespace load failed for 'rcdk': .onLoad failed in loadNamespace() ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found