Home » Questions » Computers [ Ask a new question ]

Why does my LD_LIBRARY_PATH get unset launching terminal?

Why does my LD_LIBRARY_PATH get unset launching terminal?

I have a shell script to set up some environment variables and launch whatever program I send in as an argument:

Asked by: Guest | Views: 51
Total answers/comments: 2
Guest [Entry]

"bash will use different start-up scripts depending on how it is started. There are seven different ways to start it, but the most important are login shells versus non-login interactive shells.

Check out the bash manual for more details. I would suspect the /etc/profile or the ~/.bash_profile is doing something to reset the LD_LIBRARY_PATH variable.

Edit: I think you have done all you reasonably can to show that bash does not have any startup script that unsets LD_LIBRARY_PATH. It is time to bring out the big guns.

The following command will display the entire environment as each process starts up, from bash to xterm, and anything else that happens to be involved -- you will probably get a large amount of output, so saving the output to a file is a good idea.

strace -v -f -e trace=process -o strace_output.txt envrun.sh xterm

Now, the file strace_output.txt will show each system call made by your script and every child process, and you will be able to see which process was the last to have LD_LIBRARY_PATH before it got removed."
Guest [Entry]

"Most windowing systems recreate the login process when they launch a terminal window, primarily because the terminal window becomes the child of the windowing manager not the launching shell.

So, put it in your .bash_profile or .bashrc if you want it to show up in a new window.

Another alternative is to hand xterm (for example) an argument to run a startup script. Don't exit at the end of that script...."