I am trying to establish a connection with an Informix database via my Shiny app. Whenever the server initializes and I navigate to the application, I receive this error:
[INFO] shiny-server - [/srv/shiny-server/app:55] global fileError: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Can't open lib '/opt/IBM/Informix_Client-SDK/lib/cli/iclit09b.so' : file not found
I can verify that the file is in that location, however.
I am using a custom docker image from CentOS 7 with R version 4.1.1. This is because we cannot get the Informix ODBC driver installed on Ubuntu, so using the Rocker project image is out.
I am able to connect in an rterm and through Rscript, but not when running /usr/bin/shiny-server.
file not found errors from library files can also mean that these libraries are linked against other libraries and those are missing, which is very confusing indeed. You can check that using
I've noticed that the environment of the spawned process that shiny-server starts does not contain any of the environment variables that we set on the container. We've tried using .Rprofile, .Renviron, and Renviron.site in various locations, but none of those were picked up.
How can we set up the environment variables so that the child process will also contain these?
I am not sure how to preserve LD_LIBRARY_PATH for processes being started by Shiny Server. However, I prefer a different approach for making things known to the run-time: Add a file /etc/ld.so.conf.d/local.conf with each directory containing library files on separate lines and call ldconfig afterwards. Have you tried that?
I have added our local.conf file and ran ldconfig after adding it to our image. I was able to connect to our DB through the app after hardcoding a couple environment variables from within my global.R file, which is sourced in the startup of the app.
If I could borrow your time once more: what is the best practice of setting environment variables from within the program? Is it okay to hardcode paths and read files from those paths to retrieve secret variables that cannot be environment variables?
I would expect .Renviron (or .Rprofile) to work for "normal" environment variables. LD_LIBRARY_PATH is a bit special since it is needs to be set before R starts. Have you tried that?
We have tried those, however they did not work. This was prior to you mentioning the local.conf file for the ld.so config, so I am not sure if it wouldn't work for the variables we have hardcoded into the global now. I will try this and report back.