How can I add additional paths to LD_LIBRARY_PATH on R shiny-server as the "shiny" user?

1,738 views
Skip to first unread message

claymore...@gmail.com

unread,
Apr 8, 2014, 7:21:43 PM4/8/14
to shiny-...@googlegroups.com

I am currently running Rstudio server, and now Rshiny server on Ubuntu 12.04.

I have some shared objects outside of the standard LD_LIBRARY_PATH locations that are used by some custom packages I use at work.  I want to use these packages with Shiny.

I am able to set the LD_LIBRARY_PATH for Rstudio server no problems by following these steps: http://www.rstudio.com/ide/docs/server/configuration

But I am unable to find a way to edit the LD_LIBRARY_PATH for shiny server, where the user is root (Default configuration set by you guys). How can I do this for shiny-server, to add additional paths?

When I run sudo su -c R, and type system("env") in the R session, I see that LD_LIBRARY_PATH=/usr/lib/R/lib:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server

but my attempts at appending to LD_LIBRARY_PATH in various ways have not worked.

I am guessing editing of rstudio-server.conf located in /etc/init may be necessary but I don't know how to set the environmental variable correctly.

I've tried variations of the answers provided to thishttp://stackoverflow.com/questions/21585497/connecting-to-an-oracle-database-with-roracle-on-shiny-server

but it doesn't work -- when I open the R session the LD_LIBRARY_PATH is not appended.

Furthermore, how can I append additional directories to libPaths() when R shiny-server loads, without "manually" adding to the top of the ui script .libPaths() <- c("[new location]", .libPaths())


Jeff Allen

unread,
Apr 9, 2014, 10:17:03 AM4/9/14
to shiny-...@googlegroups.com
Well the good news is that we'll be releasing Shiny Server 1.1 shortly which uses Bash profiles to start the R process. So any way that you can add an environment variable to a Bash profile (/etc/profile, ~/.bash_profile, etc.) will now work to load environment variables into a Shiny process in Shiny Server.

The bad news is that it will be a few more days before we release it formally. If you'd like, I can get you a preview release of the latest Open Source build -- assuming that you're OK running a build that hasn't been completely vetted by QA. Email me if you'd like to try it. Otherwise, keep an eye on it and you should see a new build publicly available within a week.

Jeff

claymore...@gmail.com

unread,
Apr 9, 2014, 10:45:08 AM4/9/14
to shiny-...@googlegroups.com
That's great news -  thanks for the update.  I can wait a week at this stage for this handy feature.

Clay
Message has been deleted

Jasper Drop

unread,
Sep 5, 2016, 4:25:33 AM9/5/16
to Shiny - Web Framework for R
Hope someone can help me, because i have spend many hours on this so far

I have added a two_task.sh in /etc/profile.d/ containing the following to enable the use of OracleODBC from within R:
 
export TWO_TASK="//server:port/sid"
 export ODBCINI=/usr/local/etc/odbc.ini
 export ODBCSYSINI=/usr/local/etc

This works perfectly when i (sx su - root) manually start an R-session.

My shiny server (1.4) is 'run_as root', but when it spawns R-processes that want to use the ODBC-conenction they all fail:

Warning in RODBC::odbcDriverConnect("DSN=server;UID=uid;PWD=pwd") :
  [RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver Manager]Data source name not found, and no default driver specified
Warning in RODBC::odbcDriverConnect("DSN=server;UID=uid;PWD=pwd") :
  ODBC connection failed

These are the exact same messages i got in the manual R sessions before i added the two_task.sh (see above) to /etc/profile.d/

But why are the variables not used within the spawned R-processes? According to Jef Allen from shiny-server 1.1 /etc/profile is used whenever R-processes are spawned 

I also tried setting these variables in /etc/environment, but this also does not work

> ps aux | grep R

root     12026  0.9  4.1 519784 162808 ?       Ss   08:35   0:29 /usr/lib64/R/bin/exec/R --no-save --slave -f /opt/shiny-server/R/SockJSAdapter.R
root     12028  1.1  5.0 2932872 196648 ?      Ssl  08:35   0:33 /usr/lib64/R/bin/exec/R --no-save --slave -f /opt/shiny-server/R/SockJSAdapter.R
root     12030  1.0  4.1 521612 164548 ?       Ss   08:35   0:31 /usr/lib64/R/bin/exec/R --no-save --slave -f /opt/shiny-server/R/SockJSAdapter.R

>strings /proc/12026/environ

SED=/bin/sed
R_INCLUDE_DIR=/usr/include/R
LD_LIBRARY_PATH=/usr/lib64/R/lib:/builddir/build/BUILD/R-3.3.0/curl-7.48.0/target/usr/lib64/:/builddir/build/BUILD/R-3.3.0/curl-7.48.0/target/usr/lib64:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.91-1.b14.el6.x86_64/jre/lib/amd64/server
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
PWD=/srv/shiny-server/counter
R_SHARE_DIR=/usr/share/R
R_ARCH=
SHLVL=0
HOME=/root
R_HOME=/usr/lib64/R
R_DOC_DIR=/usr/share/doc/R-3.3.0


As you can see the variables are NOT used by the spawned R-process.

what am i doing wrong ??

Jasper Drop
Reply all
Reply to author
Forward
0 new messages