Why does my $LD_LIBRARY_PATH get unset when using screen with bash?
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
.
UltraNurd
I am a software engineer and part-time CS grad student. I code by day, I game by night.
Updated on September 17, 2022Comments
-
UltraNurd over 1 year
This is related to Why does my LD_LIBRARY_PATH get unset launching terminal?, 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 /bin/tcsh {~} $ bash [~] echo $SHELL /bin/bash [~] screen -U [~]
...and when reconnecting:
{~} $ echo $SHELL /bin/tcsh {~} $ screen -dUr [~] echo $SHELL /bin/bash [~]
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?
-
Admin almost 12 yearsAs 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...
-
-
UltraNurd almost 14 yearsI'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.
-
jamesbtate over 13 years@SetJMP fixed --more characters--
-
moodboom over 8 yearsTHANK 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.