Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem setting up r-causal #73

Open
cabal-cmu opened this issue Nov 17, 2017 · 18 comments
Open

Problem setting up r-causal #73

cabal-cmu opened this issue Nov 17, 2017 · 18 comments

Comments

@cabal-cmu
Copy link

cabal-cmu commented Nov 17, 2017

@chirayukong

Hi, this problem came from Peter Spirtes, through the Helpdesk:

I tried to follow the instructions for using r-causal but I could not get it to work.

install.packages("stringr")
install.packages("rJava”)
library(devtools)
install_github("bd2kccd/r-causal")
Downloading GitHub repo bd2kccd/r-causal@master
from URL https://api.github.com/repos/bd2kccd/r-causal/zipball/master
Installing rcausal
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD
INSTALL
'/private/var/folders/ph/2js0sw_j4sd01tbfb72gm5hw0000gp/T/RtmpZOcbT1/devtools1e22f624572/bd2kccd-r-causal-7c5be55'
--library='/Library/Frameworks/R.framework/Versions/3.4/Resources/library' --install-tests

  • installing source package ‘rcausal’ ...
    ** R
    ** data
    ** inst
    ** preparing 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.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: lazy loading failed for package ‘rcausal’
  • removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rcausal’
    Installation failed: Command failed (1)

In addition, when I tried to add the libraries “rJava” using the library command, it said it couldn’t find it.

@cabal-cmu
Copy link
Author

@chirayukong

This message also came as part of the problem:

JavaVM: requested Java version ((null)) not available. Using Java at "" instead.
JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
Error : .onLoad failed in loadNamespace() for 'rcausal', details:
call: .jinit()
error: JNI_GetCreatedJavaVMs returned -1

@kingfish777
Copy link

kingfish777 commented Nov 17, 2017 via email

@cabal-cmu
Copy link
Author

@chirayukong

Update: I install the Java for OS X 2014-001 , which seemed to solve the problem of the rJava installation. I repeat all the installation process with shows no errors. I try the example for fgs continuous but get the next error:

library(rcausal)
data("charity")
fgs <- fgs(df = charity, penaltydiscount = 2, maxDegree = -1,
faithfulnessAssumed = TRUE, numOfThreads = 2, verbose = TRUE)
Error: could not find function "fgs"

@kingfish777
Copy link

kingfish777 commented Nov 17, 2017 via email

@ccd-helpdesk
Copy link

@kingfish777

Thanks. I made the adjustments, and go this error:

Error in .jnew("edu/cmu/tetrad/data/ContinuousVariable", nodname) :
java.lang.UnsupportedClassVersionError: edu/cmu/tetrad/data/ContinuousVariable : Unsupported major.minor version 52.0

@kingfish777
Copy link

kingfish777 commented Nov 17, 2017 via email

@ccd-helpdesk
Copy link

@kingfish777
javac 1.8.0_111

java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

@kingfish777
Copy link

  1. Upgrade to Oracle jdk 1.8.0_121
  2. source("http://www.bioconductor.org/biocLite.R")
  3. R > biocLite("rJava", type = "source") #this will force recompile locally
  4. sudo R CMD javareconf
  5. Run your script and report back

@ccd-helpdesk
Copy link

@kingfish777

I followed the instruction, but using Oracle jdk 9.0.1. The most recent available in the website (couldn't find older versions)

I am using the website example, changing fgs, for ages


library(rcausal)
data("charity") #Load the charity dataset

#Compute FGES search
fges <- fges(df = charity, penaltydiscount = 2, maxDegree = -1,
faithfulnessAssumed = TRUE, verbose = TRUE)


And got the next error:

Error in .jnew("edu/cmu/tetrad/data/ContinuousVariable", nodname) :
java.lang.UnsupportedClassVersionError: edu/cmu/tetrad/data/ContinuousVariable : Unsupported major.minor version 52.0

@ccd-helpdesk
Copy link

Could it be something about the new dataloaders ?

@kingfish777
Copy link

Have you restarted your R session? Also, try a reboot and go through same process. Another thing that sometimes works is to remove rJava and rcausal and perform a fresh reinstall.
If you recall a few years ago, there was a way to purge these from all of one's libraries in one line. I believe the instructions were in the instructions for Mac users, if you look back on archive.org.

@ccd-helpdesk
Copy link

So, I restarted the R version and that did not help.

There is no archived versions for the website, so I couldn't recover the instructions.

How should I purge rJava and rcausal ?

thanks

@kingfish777
Copy link

kingfish777 commented Nov 17, 2017

To remove/purge:

detach("package:rcausal", unload=TRUE)
detach("package:rJava", unload=TRUE)
remove.packages(c("rcausal", "rJava"))

But fiRst, anotheR diRty tRick: https://stackoverflow.com/questions/6979917/how-to-unload-a-package-without-restarting-r

put this into a file, say charityFges.R:

library(RBGL) 
library(rJava) # loading these seems to help in order for one's set-up to "click", I've found
library(rcausal)
data("charity")
fgs <- fges(df = charity, penaltydiscount = 2, maxDegree = -1, faithfulnessAssumed = TRUE, numOfThreads = 2, verbose = TRUE)
print(fgs)

Next, do this on the command line:
sudo Rscript charityFges.R

@kingfish777
Copy link

There are rJava tips and tricks at the bottom:
https://github.com/bd2kccd/r-causal

@ccd-helpdesk
Copy link

Thanks. I will try all these and write back when I make it work. Need to leave this for a moment.

Thanks again for the help.

@kingfish777
Copy link

rcausal.tar.gz
I have attached my local rcausal.
To install, you can

R
install.packages("rcausal.tar.gz")

@ccd-helpdesk
Copy link

ccd-helpdesk commented Nov 17, 2017 via email

@kingfish777
Copy link

Ah, yes, I think that it may have something to do with the version of Java that was used to compile the version of tetrad-lib that is included in r-causal and some conflict with the version of java that is present in the rJava config (from R CMD javareconf). That is what comes up when I jog my memory about it. I was able to fix it once locally with that problem by dropping in a compatible version of tetrad-lib into a local r-causal installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants