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 RStudio Commercial Drivers. For more information, see https://db.rstudio.com/databases/oracle/.
If you are using RStudio Server Pro, RStudio Connect, or Shiny Server Pro, then you can download and use RStudio Professional Drivers at no additional charge, available here: https://www.rstudio.com/products/drivers/download-commercial/
Configuring ROracle on RStudio 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:
echo arguments: "$@"
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:
Server.DataDirdirectory, containing all variable data used by RStudio Connect.
SQLite.Dirdirectory, which can optionally be placed outside the data directory.
- Configuration directories, including
Server.TempDir/connect-workspacesdirectory, which contains temporary directories, one per R process.