I have built and installed an application under a directory of my choosing, let's say under /home/jim/usr, so files have been put in three-four folders, all under this $HOME/usr folder (e.g., bin, include, lib, share, etc.).

I can launch this application from the command line just fine as I added the proper paths to my environement variables PATH and LD_LIBRARY_PATH in ~/.bashrc.

I added the same paths to the ~/.profile file, which, if I'm not mistaken, is supposed to be parsed by Ubuntu.

Doesn't work. Nothing. Where can I go from there?

EDIT: I logged out/in and restarted my computer. Both didn't change a thing. The problem seems to come from the fact that no matter what I do the LD_LIBRARY_PATH environment variable is not properly passed to Ubuntu.

Using log files, I found that the application I'm trying to run in this example doesn't find one it's dependencies located in ~/usr/lib.

One solution would be to add the /home/jim/usr/lib folder inside a file located in /etc/ld.so.conf.d/, but I don't have admin rights on this machine.

Making a wrapper script like this one works:

export LD_LIBRARY_PATH=$HLOC/usr/lib
application &> $HOME/application_messages.log

but that would force me to wrap all my home compiled applications with this script. Any ideas?

Why does Ubuntu/Gnome remove the LD_LIBRARY_PATH environment variable from my set variables? Is it because trying to do this is bad practice?

UPDATE (and solution): As found by Christopher, there is a bug report about this on launchpad. LD_LIBRARY_PATH is unset after parsing of the ~/.profile file. See the bug report. Seems the only solution for now is to make a wrapper script.

  • Were those environment variables available only within your shell (having used 'source' within the shell)? If so, logout. Login. – user8290 Feb 9 '11 at 17:30
  • @Christopher, I know of no way to tell whether those environment variables are accessible to Ubuntu (i.e., to an application launched from the Applications menu). The env variables don't seem to be accessible, which is why my application fails to start from the menu. How do I check if they are accessible?? – levesque Feb 9 '11 at 18:49
  • Open a new shell - without sourcing anything like .bashrc/.profile - and see if the variables are there. – user8290 Feb 9 '11 at 18:51
  • @Christopher, The modifications to my PATH environment variable are there, but LD_LIBRARY_PATH seems to be missing. – levesque Feb 9 '11 at 19:03
  • 1
    Oh... it's a bug: edge.launchpad.net/ubuntu/+bug/366728 – user8290 Feb 9 '11 at 19:56

Create a file for it:

sudo vim /etc/ld.so.conf.d/my_application.conf

And the contents of that file:


Save. Rebuild the cache:

sudo ldconfig -v
  • Thanks, but I had done this already. Anyway, if I'm not mistaken, the environment variables defined in bashrc are not used by nautilus/gnome, unless the applications are launched in terminal mode... – levesque Feb 9 '11 at 19:14
  • Hmmm. Does it help to use the dynamic linker run-time bindings, added to solution? – user8290 Feb 9 '11 at 19:21
  • Adding the lib folder in ld.so.conf.d works, but I don't have admin rights on this machine (I know, eww). – levesque Feb 9 '11 at 19:36
  • It's a bug: edge.launchpad.net/ubuntu/+bug/366728 – user8290 Feb 9 '11 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.