Preface
This article assumes Oracle Instant Client Basic & SDK, and ROracle, are already installed. For assistance installing ROracle, visit this page.
As an alternative to ROracle, you may wish to consider using the DBI R package and the Posit Commercial Drivers. For more information, see https://solutions.posit.co/connections/db/databases/oracle/.
If you are using Posit Workbench, Posit Connect, or Shiny Server Pro, then you can download and use Posit Professional Drivers at no additional charge, available here:
https://docs.posit.co/pro-drivers/install/
Configuring ROracle on Posit Connect
The final steps of the ROracle Installation involve setting several paths in the environment to include LD_LIBRARY_PATH, OCI_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 "$@"
Note: In this example, /opt/scripts/ was used to store the script to avoid any directories masked by the sandbox. The following locations are masked during R execution:
- The
Server.DataDir
directory, containing all variable data used by RStudio Connect. - The
SQLite.Dir
directory, which can optionally be placed outside the data directory. - Configuration directories, including
/etc/rstudio-connect
. - The
Server.TempDir/connect-workspaces
directory, which contains temporary directories, one per R process.
Comments