[Rd] R started in terminal shell script or ESS steps on LD_LIBRARY_PATH?

Marc Schwartz (via MN) mschwartz at mn.rr.com
Tue Mar 7 21:30:09 CET 2006


Hi all,

Just noted this behavior in the past couple of days, where if R is
started in a shell script such as:

  gnome-terminal [-e][-x] R

or in ESS (version 5.2.12 with Emacs or XEmacs), the LD_LIBRARY_PATH
environment variable is not properly appended to, resulting in the loss
of the pre-start value.

This is using R Version 2.2.1 Patched (2006-02-28 r37448) on FC4.

I noted this when attempting to access an Oracle 10g server using RODBC
(version 1.1-5) and to the best of my recollection, this is a new
problem.

It took me a while to figure this out and was about to send an e-mail to
r-sig-db since I was having trouble connecting using odbcConnect(), when
I noted the problem with LD_LIBRARY_PATH. I noted this quite by accident
as I was writing the e-mail to r-sig-db.

I was on the verge of mental vapor lock with this, so if I missed a
documented change in behavior, my apologies. In looking at the R startup
script, it seems appropriate in terms of appending to the existing
value. So it seems that this is being altered elsewhere presumably.



In the two cases I note above, I get:

> Sys.getenv("LD_LIBRARY_PATH")
                                     LD_LIBRARY_PATH 
"/usr/local/lib/R/lib:/usr/local/lib:/usr/X11R6/lib"


whereas the pre-start value is:

  LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.1/client/lib



Importantly, if I start a gnome-terminal session and then start R from
the command line, I get:

> Sys.getenv("LD_LIBRARY_PATH")

LD_LIBRARY_PATH
"/usr/local/lib/R/lib:/usr/local/lib:/usr/X11R6/lib:/usr/lib/oracle/10.2.0.1/client/lib"


In this case, I can use odbcConnect() to the Oracle server and it works
the first time, every time.

This suggests to me some type of problem in the inheritance of the
pre-session environment in the two former cases, but again, I may be
missing something.


Even if I try:

LD_LIBRARY_PATH <- Sys.getenv("LD_LIBRARY_PATH")

Sys.putenv(LD_LIBRARY_PATH = paste(LD_LIBRARY_PATH,
           "/usr/lib/oracle/10.2.0.1/client/lib", sep = ":"))

and then:

> Sys.getenv("LD_LIBRARY_PATH")

LD_LIBRARY_PATH 
"/usr/local/lib/R/lib:/usr/local/lib:/usr/X11R6/lib:/usr/lib/oracle/10.2.0.1/client/lib" 


I still cannot get odbcConnect() to work. I still get the error that I
was getting in the two initial R startup situations:

Warning messages:
1: [RODBC] ERROR: state 01000, code 0, message [unixODBC][Driver
Manager]Can't open lib
'/usr/lib/oracle/10.2.0.1/client/lib/libsqora.so.10.1' :
libclntsh.so.10.1: cannot open shared object file: No such file or
directory 
2: ODBC connection failed in: odbcDriverConnect(st, case = case,
believeNRows = believeNRows)


The above error is what has been driving me nuts for the past two days,
since clearly these files are present and it works in R from the
gnome-terminal command line and when using the sql*plus instant client
directly.  The LD_LIBRARY_PATH issue is the only one that I have noted
that appears to be different.


Any ideas on this?  Did I miss a change someplace?

Thanks for any insights.

Marc Schwartz



More information about the R-devel mailing list