Unable to connect to Informix database using DBI and ODBC

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.

Any help would be appreciated.

Thank you.

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

ldd /opt/IBM/Informix_Client-SDK/lib/cli/iclit09b.so

Does that list any dependencies as "not found"? If yes, please install them and/or make sure they are found by the runtime linker.

Thank you for your response. I was able to verify that the libifgls and libifglx libraries were missing, so I installed those.

However, running the application still gives me the same file not found error.

This screenshot shows that from the terminal it is possible to still connect with ISQL, so ODBC is working still.

I also have this snippet in a test file and can verify a connection if I run it through Rscript.

odbc_con <- DBI::dbConnect(odbc::odbc(),
  Driver = "Informix",
  Database = "#####",
  UID = "######",
  PWD = "######",
  host = "######",
  PortNumber = ####,
  ServerName = "###"
)

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?

Thanks!

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?

Thank you for all your help.

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.

It appears that does work. Thank you for all your help.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.