QBoard » Artificial Intelligence & ML » AI and ML - R » ROracle not working in R studio

ROracle not working in R studio

  • 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.

      October 1, 2021 1:29 PM IST
    0
  • The final steps of the ROracle Installation involve setting several paths in the environment to include LD_LIBRARY_PATHOCI_LIB, and ORACLE_HOME.

    The LD_LIBRARY_PATH must be set prior to the R process executing.  Using R startup files such as Renviron.site and Rprofile.site will not suffice, since the R process has already started.  The ideal way to set this value is to use a Program Supervisor script.

    As an example, here is a configuration that uses a custom script to prepare a custom execution environment before finally running R.  

    Add the following to: /etc/rstudio-connect/rstudio-connect.gcfg

    [Applications]
    Supervisor = /opt/scripts/environment.sh

    Then, the contents of example environment.sh could be something like:

    #!/bin/bash
    
    echo arguments: "$@" >&2
    echo >&2
    
    export LD_LIBRARY_PATH="/usr/lib/oracle/11.2/client64/lib:$LD_LIBRARY_PATH"
    export OCI_LIB="/scratch/instantclient_11_2"
    export ORACLE_HOME="/path/to/oracle/home/"
    
    exec "$@"

     

      December 27, 2021 1:45 PM IST
    0
  • No. I was thinking of ROracle as being the database specific and therefore 'best' option to instantiate a connection.

    I was previously having issues using the bind feature with the obdc package. However, that was before the latest release. I'll go back and give it a try.

    if all you have is a hammer, everything looks like a nail

    Thank you for the response!

      December 4, 2021 1:21 PM IST
    0
  • 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.

     
      October 1, 2021 11:52 PM IST
    0
  • 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
    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.

      October 6, 2021 3:48 PM IST
    0