[Bug: 21.4.18] compile command path not that of login shell

Glynn Clements glynn at gclements.plus.com
Sun May 28 18:38:50 EDT 2006


Larry Evans wrote:

> > --text follows this line--
> > ================================================================
> > Dear Bug Team!
> > 
> > The following is my response to Stephen Tumbull's post:
> [snip]
> >  > Do you get the same results (bad behavior with compile, and the
> >  > various values for PATH I've requested above for your usual
> >  > environment) if XEmacs is invoked with "xemacs -vanilla"?
> > 
> > No! With "xemacs -vanilla", in the 'shell command toll', I get
> > the correct, longer value.  Maybe that's the important clue!
> > 
> I've discovered something else important.  The problems I was
> reporting did not start from invokation from an xterm.  Instead,
> they started from an icewm menu item.  The code executed when
> I pressed this item was:
> 
>      prog    "XEmacs21-nomule" - /bin/sh -c "/usr/bin/xemacs21-nomule"
> 
> OTOH, when:
> 
>      /usr/bin/xemacs21-nomule
> 
> is executed from a terminal, the problem with PATH disappears.

XEmacs will inherit environment variables from its parent. If you run
it from an interactive shell in an xterm, it will inherit the shell's
environment, which will typically include anything set by ~/.bashrc;
if you run it from a WM menu, it will inherit the WM's environment,
which won't necessarily include anything set by ~/.bashrc.

If you start an interactive shell with "M-x shell" or the
"Tools/Shell/Shell" menu option, the shell itself will source ~/.bashrc.
OTOH, if you use the shell to run a single command ("sh -c ...",
which is what M-! or "Tools/Shell/Shell Command..." does), the shell
won't read ~/.bashrc (or any other file).

To ensure that commands run with M-! etc get the relevant environment
variables, you can either:

1. Change the WM menu entry to run a wrapper script along the lines
of:

	#!/bin/bash
	source ~/.bashrc
	exec /usr/bin/xemacs21-nomule

2. Add a bunch of (setenv "PATH" "...") etc calls to your init.el
file.

3. Configure your ~/.xsession (or similar) script to source ~/.bashrc
before starting the WM. Then, programs run from the WM should get the
same environment as those run from a terminal.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the XEmacs-Beta mailing list