ENV['LD_LIBRARY_PATH'] not changing env

Discussion in 'Ruby' started by TDR, Aug 10, 2007.

  1. TDR

    TDR Guest

    Ruby 1.8.6 on solaris 9.

    I am a newbie.
    I need to set LD_LIBRARY_PATH within my script as follows:

    ENV['LD_LIBRARY_PATH'] = '/usr/local/mysql/lib/mysql:/usr/local/
    easysoft/unixODBC/lib:/usr
    /local/easysoft/lib'

    but it doesn't seem to be "taking". I get the error I would expect to
    get when LD_LIBRARY_PATH is not set:

    s00c166.ssa.gov# ruby -r debug process_ond.rb
    Debug.rb
    Emacs support available.

    process_ond.rb:29:def lookup_cid(off_id)
    (rdb:1) b 95
    Set breakpoint 1 at process_ond.rb:95
    (rdb:1) c
    Breakpoint 1, toplevel at process_ond.rb:95
    process_ond.rb:95:ENV['LD_LIBRARY_PATH'] = '/usr/local/mysql/lib/
    mysql:/usr/local/easysoft/unixODBC/lib:/usr/local/easysoft/lib'
    (rdb:1) n
    process_ond.rb:99:$dbh_ditm = DBI.connect("DBI:Mysql:ditm:localhost",
    "ditmusr", "xxxxxx")
    (rdb:1) n
    /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:344: `Could not load driver
    (ld.so.1: ruby: fatal: libmysqlclient.so.15: open failed: No such file
    or directory - /usr/local/lib/ruby/site_ruby/1.8/sparc-solaris2.9/
    mysql.so)' (DBI::InterfaceError)
    from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:344:in
    `load_driver'
    from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:227:in
    `_get_full_driver'
    from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:213:in `connect'
    from process_ond.rb:99
    /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:344: raise
    InterfaceError, "Could not load driver (#{$!.message})"
    (rdb:1)

    But when I set LD_LIBRARY_PATH in my shell, prior to running the
    script, I don't get this error:

    s00c166.ssa.gov# setenv LD_LIBRARY_PATH '/usr/local/mysql/lib/mysql:/
    usr/local/easysoft/unixODBC/lib:/usr/local/easysoft/lib'
    s00c166.ssa.gov# ruby -r debug
    process_ond.rb Debug.rb
    Emacs support available.

    process_ond.rb:29:def lookup_cid(off_id)
    (rdb:1) b 99
    Set breakpoint 1 at process_ond.rb:99
    (rdb:1) c
    Breakpoint 1, toplevel at process_ond.rb:99
    process_ond.rb:99:$dbh_ditm = DBI.connect("DBI:Mysql:ditm:localhost",
    "ditmusr", "xxxxxx")
    (rdb:1) n

    What am I doing wrong here?

    TDR
     
    TDR, Aug 10, 2007
    #1
    1. Advertising

  2. TDR

    ara.t.howard Guest

    On Aug 10, 2007, at 8:25 AM, TDR wrote:

    >
    > ENV['LD_LIBRARY_PATH'] = '/usr/local/mysql/lib/mysql:/usr/local/
    > easysoft/unixODBC/lib:/usr
    > /local/easysoft/lib'


    you may be clobbering an existing (required) env setting - try this:

    ENV[ 'LD_LIBRARY_PATH' ] = [
    '/foo',
    '/bar',
    ENV[ 'LD_LIBRARY_PATH' ],
    ].join(':')

    a @ http://drawohara.com/
    --
    we can deny everything, except that we have the possibility of being
    better. simply reflect on that.
    h.h. the 14th dalai lama
     
    ara.t.howard, Aug 10, 2007
    #2
    1. Advertising

  3. TDR

    TDR Guest

    On Aug 10, 10:22 am, TDR <> wrote:
    > Ruby 1.8.6 on solaris 9.
    >
    > I am a newbie.
    > I need to setLD_LIBRARY_PATHwithin my script as follows:
    >
    > ENV['LD_LIBRARY_PATH'] = '/usr/local/mysql/lib/mysql:/usr/local/
    > easysoft/unixODBC/lib:/usr
    > /local/easysoft/lib'
    >
    > but it doesn't seem to be "taking". I get the error I would expect to
    > get whenLD_LIBRARY_PATHis not set:


    I had originally assumed this to be a problem with setting any
    environment variables. It turns out LD_LIBRARY_PATH is a special
    case. The syntax for setting environment variables in ruby worked
    fine for TNS_ADMIN.

    Moreover, I came across a posting somewhere today that explains why
    not to use LD_LIBRARY_PATH, but rather LD_RUN_PATH. So the situation
    in this posting, it turns out, is specific to LD_LIBRARY_PATH.

    Hope this helps someone.
     
    TDR, Aug 31, 2007
    #3
  4. On Aug 31, 10:10 am, TDR <> wrote:
    > On Aug 10, 10:22 am, TDR <> wrote:
    >
    > > Ruby 1.8.6 on solaris 9.

    >
    > > I am a newbie.
    > > I need to setLD_LIBRARY_PATHwithin my script as follows:

    >
    > > ENV['LD_LIBRARY_PATH'] = '/usr/local/mysql/lib/mysql:/usr/local/
    > > easysoft/unixODBC/lib:/usr
    > > /local/easysoft/lib'

    >
    > > but it doesn't seem to be "taking". I get the error I would expect to
    > > get whenLD_LIBRARY_PATHis not set:

    >
    > I had originally assumed this to be a problem with setting any
    > environment variables. It turns out LD_LIBRARY_PATH is a special
    > case. The syntax for setting environment variables in ruby worked
    > fine for TNS_ADMIN.
    >
    > Moreover, I came across a posting somewhere today that explains why
    > not to use LD_LIBRARY_PATH, but rather LD_RUN_PATH. So the situation
    > in this posting, it turns out, is specific to LD_LIBRARY_PATH.


    You can usually avoid setting either one (on Solaris, at least) if the
    underlying libraries have been built with the runtime library path set
    properly. In some case this means running the configure script, then
    hand editing the Makefile and adding "-R /path/to/lib".

    Regards,

    Dan
     
    Daniel Berger, Aug 31, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christian Eriksson

    Problem using LD_LIBRARY_PATH in perl script

    Christian Eriksson, Nov 24, 2003, in forum: Perl
    Replies:
    1
    Views:
    3,208
  2. Naresh Agarwal
    Replies:
    0
    Views:
    838
    Naresh Agarwal
    Jun 30, 2005
  3. Simon John
    Replies:
    2
    Views:
    700
    Simon John
    Sep 19, 2004
  4. Replies:
    0
    Views:
    324
  5. Lax
    Replies:
    2
    Views:
    366
    Peter J. Holzer
    Apr 14, 2007
Loading...

Share This Page