National-COVID-Cohort-Collaborative / Phenotype_Data_Acquisition

The repository for code and documentation produced by the N3C Phenotype and Data Acquisition workstream
60 stars 35 forks source link

Unable to load N3CHDSI library: unable to load shared object library #223

Closed riqi-rob-mcconeghy closed 2 years ago

riqi-rob-mcconeghy commented 2 years ago

Hello wonderful contributors to this important cause!!

I haven't changed my code since July, when I was able to successfully run our full N3C pipeline.

Went to run it today, couldn't get past first line: > library(N3cOhdsi)

I think it's something where R needs to look up that library file? I didn't change the code but maybe something changed behind the scenes? Could be a link or a environment variable? This is probably on my end, not on yours, but I'll take any solution I can get :)

riqi-rob-mcconeghy commented 2 years ago

I've been playing with the .Rprofile and .Renviron files, trying to supply them the correct path as the .libPath() function. R doesn't want to find the N3C or rJava libraries even though they're definitely there.

riqi-rob-mcconeghy commented 2 years ago

The error message: Loading required package: DatabaseConnector Error: package or namespace load failed for ‘DatabaseConnector’: .onLoad failed in loadNamespace() for 'rJava', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/home/user_name/R/x86_64-pc-linux-gnu-library/4.1/rJava/libs/rJava.so': libjvm.so: cannot open shared object file: No such file or directory Error: package ‘DatabaseConnector’ could not be loaded

daneckrich commented 2 years ago

not sure if it's the same issue, but I have seen that error after server updates. I tend to have to run the following command after the update to get R to work with Java again:

R CMD javareconf

riqi-rob-mcconeghy commented 2 years ago

My issue seems to be solved! I followed the guide linked below. It seems JAVA_HOME was "" aka blank, but I put into the .Rprofile a conditional where if that's the case, then setenv for JAVA_HOME to be the place within our linux system where the Java is located.

https://biostatsr.blogspot.com/2018/02/set-javahome-to-correct-value-in-profile.html