Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is related to, but a different set of symptoms.

First, /usr/bin/screen is setuid as per the other question. Second, the default shell on this system is /bin/tcsh for various historical reasons, and we're not allowed to chsh to /bin/bash, so I typically run bash manually immediately after login. Third, I almost always use screen, but I want ctrl-a ctrl-c in screen to create a new bash "tab", so I always invoke bash first.

That is:

{~} $ echo $SHELL
{~} $ bash
[~] echo $SHELL
[~] screen -U

...and when reconnecting:

{~} $ echo $SHELL
{~} $ screen -dUr
[~] echo $SHELL

However, my $LD_LIBRARY_PATH is there in tcsh, there in bash, but empty once I run screen; it is still present if I just run screen from tcsh, but then I get new tcsh "tabs" when I use ctrl-a ctrl-c in screen.

Any ideas?

share|improve this question
As in my comment to that other question you linked: LD_LIBRARY_PATH is good for debugging / short-term patching binaries, but as a constant addition to your environment, it's a mistake. So I'd recommend that, once you understood why it isn't set in your case, you remove the need for setting it wholesale... – DevSolar Jul 16 '12 at 9:49
up vote 6 down vote accepted

Because screen is setuid, it unsets LD_LIBRARY_PATH. When your shell is tcsh, tcsh initialisation (from .tcshrc I suppose, since screen doesn't default to creating login shells) sets LD_LIBRARY_PATH again. If you want LD_LIBRARY_PATH to be set in your bash screen windows, set it from .bashrc.

share|improve this answer
THANK you I just combed half the internet and wrote a bunch of bash scripts to figure this out, before getting it confirmed here. I like to set LD_LIBRARY_PATH and LDFLAGS based on the software I'm developing, not globally. At least now I know where things are going wrong for me now. – moodboom Nov 19 '15 at 0:49

Most people set their $PATH and $LD_LIBRARY_PATH in .bash_profile or .bashrc thinking they are both the same but this is not true. One is for "true shells" and one is for "remote shells" is my understanding of it (I can never remember which is which). Basically, depending on how you login (ssh, desktop terminal, screen, w/e), one is executed or the other. If you have your variables set in one but not the other, consider making one a sym-link to the other or making it a one-liner:

echo "source .bashrc" > .bash_profile

*assuming you use .bashrc now; otherwise:

echo "source .bash_profile" > .bashrc

so that your variables are set no matter how you log in.

share|improve this answer
I'm pretty sure this isn't a problem with my bash config, since $LD_LIBRARY_PATH is still inherited from tcsh properly when running bash directly; it's only a problem in the interaction between bash and screen. – UltraNurd Jun 16 '10 at 22:06
I believe its .bashrc not .bash_rc. – SetJmp Dec 29 '10 at 18:17
@SetJMP fixed --more characters-- – Puddingfox Dec 31 '10 at 22:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .