ecohealthalliance / ehastyle

R Markdown templates for EHA documents
8 stars 3 forks source link

Unable to install - rJava error #8

Closed brooke-watson closed 6 years ago

brooke-watson commented 6 years ago

I think this may have something to do with upgrading to R 3.5, but I'm unable to re-install ehastyle (or any packages that depend on rJava, for that matter).

Currently attempting to re-download 64 bit Java, but filing this issue in case someone else runs into the same problem. I'll close (& maybe add to the readme?) if any of these things work.

This is the error I get:

> devtools::install_github("ecohealthalliance/ehastyle")
Using GitHub PAT from envvar GITHUB_PAT
Downloading GitHub repo ecohealthalliance/ehastyle@master
from URL https://api.github.com/repos/ecohealthalliance/ehastyle/zipball/master
Installing ehastyle
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file  \
  --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/3f/11vgjp4d4371gqchfd64vwhm0000gn/T/RtmpUzY7gH/devtools112fc3cfb30/ecohealthalliance-ehastyle-02c4a3b'  \
  --library='/Library/Frameworks/R.framework/Versions/3.5/Resources/library'  \
  --install-tests 

* installing *source* package ‘ehastyle’ ...
** R
** inst
** byte-compile and prepare package for lazy loading
Error : .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-9.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
ERROR: lazy loading failed for package ‘ehastyle’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/ehastyle’
Installation failed: Command failed (1)

I can allegedly download rJava, but I can't load it.

> install.packages("rJava")
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/rJava_0.9-10.tgz'
Content type 'application/x-gzip' length 735656 bytes (718 KB)
==================================================
downloaded 718 KB

The downloaded binary packages are in
    /var/folders/3f/11vgjp4d4371gqchfd64vwhm0000gn/T//RtmpUzY7gH/downloaded_packages
> library(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.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-9.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
brooke-watson commented 6 years ago

update: magically fixed with sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /Library/Frameworks/R.framework/Libraries in terminal!