How to let Shiny server to find specific system dependency

Hi All, I am working on my shiny app development, which is deployed on an internal shiny server. There is a download button which should create a dynamic html file based on users' selections and download the html file to local end.

However, the function failed to work. I tried some diagnoses myself. It turns out to be that the shiny server is looking into the wrong directory for a dependency "libstdc++.so.6". Attached is the detailed error message from log file:

Warning: Error in dyn.load: unable to load shared object '/share/apps/R/4.0.2/lib64/R/library/stringi/libs/stringi.so':
/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /share/apps/R/4.0.2/lib64/R/library/stringi/libs/stringi.so)
[No stack trace available]

I've checked the shiny server, there are currently two different paths that has "libstdc++.so.6", one is located at "/share/apps/CentOS-7/gcc/r-7.2/lib64" and the other is located at "/lib64", the first location has the correct version of "CXXABI_1.3.8" while the other one doesn't. So somehow shiny server only look up libstdc++.so.6 from the second location, which doesn't have the correct version of "CXXABI_1.3.8"

My question is how should I let shiny server know where to find the current library/dependency while loading.

Things I've tried but still failed:
I added an environment path at the first line of my server.R by using Sys.setenv(LD_LIBRARY_PATH = "/share/apps/CentOS-7/gcc/r-7.2/lib64") to tell shiny server the correct location

It's been making my head scratchy for over a week. Any help or suggestion will be much appreciated!

Note that I've never encountered this issue myself, but after some searching, it looks like your approach is correct but for whatever reason, setting the directory path through Sys.setenv doesn't work, at least for this user.

I think Shiny server uses bash profile to get environmental variables, have you tried that approach? Assuming you have the directory correct, you can edit ~/.bashrc or ~/.bash_profile to include the additional path using:

export LD_LIBRARY_PATH=/share/apps/CentOS-7/gcc/r-7.2/lib64:/lib64:$LD_LIBRARY_PATH

Disclaimer: it might not work at all since I have no way of testing this. Just something I found online.