A common requirement is to adjust the LD_LIBRARY_PATH or add additional environment variables on all Connect applications to allow certain R packages or other resources to work with your deployed applications. For example: ROracle, Gurobi, Hadoop, etc.
We suggest placing these environment variable changes into the program supervisor script, this way it's set in the shell prior to the application process starting. This is critical for the LD_LIBRARY_PATH edits to take effect.
Note: If you only need the environment variable available after the R process starts (e.g. if it contains a password or secret, instead of a path modification), the best practice is to use the environment variable pane instead.
To implement, follow these steps:
1. Create a directory to store your program supervisor script. Note that this directory must be accessible by the sandbox. Below is an ideal directory example:
mkdir -p /opt/scripts
2. Example script contents to edit for your needs:
echo arguments: "$@" >&2
3. Allow access to the file with:
chmod 755 /opt/scripts/connect-env.sh
4. Add the following to /etc/rstudio-connect/rstudio-connect.gcfg
Supervisor = /opt/scripts/connect-env.sh
Once complete, restart the RStudio Connect service then attempt to deploy or access the existing application.