ROracle not working in R studio
Asked Answered
M

2

8

I'm trying to install ROracle package on a unix box. The package gets installed properly. But library(ROracle) does not work fine with the error

library(ROracle)
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
unable to load shared object '/u01/group1/home/oracle/R/x86_64-redhat-linux-gnu-library/3.1/ROracle/libs/ROracle.so':
libclntsh.so.11.1: cannot open shared object file: No such file or directory
Error: package or namespace load failed for ‘ROracle’

The package installs fine from the command line , but just does not work in R studio. I went through lot of threads in forum and lot of them suggested to export the LD_LIBRARY_PATH and reset it.infact i went ahead and copied all the R system variables from command line into R Studio. But it still does not work out fine.

One thing i have also noticed is that the R system variables change every time i restart R studio. Can it be the problem that R studio is not taking path values correctly.

Marinmarina answered 19/1, 2015 at 13:36 Comment(6)
It doesn't work in RStudio, but it works in vanilla R from the console?Populace
Yes Roman. U are rightMarinmarina
I had another thought. Why is this tagged rstudio-server? Are you accessing R through the server or directly?Populace
I am having the same issue. Were you able to make it work on the Rstudio?Tabina
I'm having the exact same issue in CentOS - and all "usual supects" env variables look correct from within RStudio (LD_LIBRARY_PATH, ORACLE_HOME, ORACLE_SID)Faldstool
see also #14882533 dyn.load("/usr/lib/oracle/11.2/client64/lib/libclntsh.so.11.1"); library(ROracle)Heaves
L
13

Seems that the problem is caused by the $LD_LIBRARY_PATH environment variable not being set in a way that is system-wide. Unlike other environment variables, $LD_LIBRARY_PATH needs special treatment (see the Ubuntu Help page and search for ld.so.conf.d)

I was able to solve this by setting the $LD_LIBRARY_PATH as per comment 15:

echo "/usr/lib/oracle/11.2/client64/lib" | sudo tee /etc/ld.so.conf.d/oracle.conf

Change the echo statement to where your Oracle Instant Client libraries are stored. (Mine could be found by running echo $OCI_LIB.

Then update the cache:

sudo ldconfig -v

Then open RStudio, execute library("ROracle") and it should work.

Leontina answered 24/4, 2016 at 11:30 Comment(2)
Josh Gilfillan, I found your answer very helpful. To people administering Debian based systems that interface with Oracle, I would highly recommend reading the following documentation regarding shared libraries.Silvers
@Zerodf, glad it was helpful. Any chance of an up-vote? :)Leontina
F
3

I had the exact same problem, and I have just resolved it thanks to a conference with some very kind and helpful Oracle personnel.

We need to include the following line in /etc/rstudio/rserver.conf file (which by default is empty):

rsession-ld-library-path=/usr/lib64/R/lib:/u01/app/oracle/product/12.1.0.2/dbhome_1/lib

i.e. the R & Oracle home directories:

$ echo $R_HOME
/usr/lib64/R
$ echo $ORACLE_HOME
/u01/app/oracle/product/12.1.0.2/dbhome_1

You have to restart the RStudio server after modifying the configuration file.

I have checked this only with RStudio server, so not sure if it is necessary for RStudio Desktop, too...

See here for more details (although it refers to Oracle R Enterprize, it is also applicable to vanilla R).

Faldstool answered 30/10, 2015 at 10:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.