Re: environment variables

Aaron Davies <[email protected]>
Newsgroups gmane.comp.gnu.screen.user
Message-ID <[email protected]>
On Dec 11, 2013, at 6:06 AM, Nico Schlömer wrote:

> David T. Pierson <dtp-tWP3OOf8k3DqlBn2x/[email protected]> wrote:

> 
>> If you want different behavior, please be more specific about what you are really trying to accomplish.
> 
> I would like to execute a program in a shell that needs a custom path added to  LD_LIBRARY_PATH. This happens in my .bashrc by default, so on the regular non-screen shell I'm getting no problems.
> 
> On a detached screen however, the program will not execute with an error message related to an incomplete LD_LIBRARY_PATH. Indeed,
> 
> $ env | grep LD_LIBRARY_PATH
> LD_LIBRARY_PATH=/home/nschloe/Work/FEniCS/lib/:/opt/trilinos/dev/openmpi/1.4.3/gcc/4.6.3/release/shared/lib/:/opt/netcdf/4.2.1.1/lib/:/home/nschloe/Work/FEniCS/lib:
> $ screen -L -d -m sh -c "env | grep LD_LIBRARY_PATH"
> $ cat screenlog.0
> $
> 
> so LD_LIBRARY_PATH doesn't seem to be defined in the detached shell at all.
> 
> It *does* get set in attached shells though.
> 
> Any workaround for it?

shell initialization is weird, tricky, and annoying

things to check:

is LD_LIBRARY_PATH exported? try "export | grep LD_LIBRARY_PATH". if not, change your .bashrc to export it.

how is your .bashrc called? the default rule in bash 3.2 (the man page i have most direct access to at the moment) is "When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists."

how is screen launching your shell? is the screen "shell" config "bash" or "-bash"? is it set at all, or is it defaulting to $SHELL?

do you call your .bashrc from your .bash_profile? (do you *have* a .bash_login or .profile?) a very common bash idiom is to have "[[ -f ~/.bashrc ]] && . ~/.bashrc" in .bash_profile.

is this OS X or linux/bsd/cygwin windows/something else? i've heard reports of shell initialization differences in OS X zsh, so there might be issues in bash too.
-- 
Aaron Davies
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.