1

when i login a remote server through ssh, i see the LD_LIBRARY_PATH was :

echo $LD_LIBRARY_PATH
:/usr/local/lib

And when i use fabric in python, to run the same code in fabric run api, the result is empty.

from fabric.api import *
def test():
    run("echo $LD_LIBRARY_PATH")

and even when i try to change the LD_LIBRARY_PATH using fabric, it doesn't work at all.

from fabric.api import *
def test():
    run("echo $LD_LIBRARY_PATH")
    run("export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH")

Does anyone know why?

holsety
  • 323
  • 1
  • 2
  • 13
  • The answer here probably explains why: http://stackoverflow.com/questions/216202/why-does-an-ssh-remote-command-get-fewer-environment-variables-then-when-run-man – Josh Smeaton Feb 21 '13 at 09:19
  • You get far fewer environment variables when fabric sshs. After exporting LD_LIBRARY_PATH from fabric, does echo return the new path you've set? – Josh Smeaton Feb 21 '13 at 09:19
  • i think, the each `run` function use a separate link to the remote server, so the LD_LIBRARY_PATH is set to empty in the next run. – holsety Feb 21 '13 at 09:25
  • I don't think so, I was reading the fabric docs the other day, and it caches the connections and login info etc. – Josh Smeaton Feb 21 '13 at 09:33
  • possible duplicate of [Best way to add an environment variable in fabric?](http://stackoverflow.com/questions/8313238/best-way-to-add-an-environment-variable-in-fabric) – Josh Smeaton Feb 21 '13 at 09:35
  • 2
    Voting to close because your Question is answered in the linked Q. – Josh Smeaton Feb 21 '13 at 09:36

1 Answers1

0

I had the same problem and here is a way to fix it. You need at least fabric 1.5.4 i think to use shell_env.

with shell_env(LD_LIBRARY_PATH ="/usr/local/lib"):
    run('something')
Romanzo Criminale
  • 1,289
  • 2
  • 14
  • 21