[Xquartz-dev] env variables and launchd problem

Dave Ray apple at jonive.com
Wed Mar 23 13:04:02 PDT 2011


On Mar 23, 2011, at 11:44 AM, Jeremy Huddleston wrote:

> Did you miss my response to you?  Or did you miss my response to him that his statement is actually incorrect.

I saw your post, but what you are describing is not consistent to what I'm observing on my machine. It's not that I don't believe you, I am just trying to understand why.

>> So the problem is not a config issue on my machine, others are seeing it. This helps me enormously. 
> 
> As I mentioned earlier, it has to do with X11.app inheriting a login shell environment from ~/.bash_profile, ~/.bash_login, or ~/.profile ... which means it does not use ~/.bashrc.  Non-login shells use ~/.bashrc.  If you want your ~/.bashrc used in login shells as well, make sure you source it in your ~/.bash_profile

I never used ~/.bashrc. I never said I did.

My /etc/profile, which the shell is correctly invoking, loads /etc/bashrc. This is normal. The /etc/profile that comes with Snow Leopard does this and there is nothing wrong with it. Terminals all have the correct expected env from .etc/bashrc because it is being correctly invoked by /etc/profile. X11 is different.

>> I am also using  ~/.MacOSX/environment.plist as a work-around, to make sure the right ENV gets passed to X11 when it is launched by launchd.
> 
> Use ~/.profile (or ~/.bash_profile)... *especially* if you're on Leopard because environment.plist does not get set in LaunchAgents, so if X11.app is forked from /usr/X11/bin/X from /usr/X11/bin/xinit from launchd, you will not have the environment.plist environment, but you *WILL* have your login shell environment.

As I said in my previous posts I am using Snow Leopard. 

To satisfy your suggestion: if I copy /etc/bashrc to ~/.bash_profile, and/or to ~/.profile, nothing changes. I can have copies of /etc/bashrc in ~/.bash_profile and ~/.profile at the same time and get the same results. That's because this is not the source of the problem. A different env is being passed to X11, even with those files in place.

To reiterate, I am starting up X11 with only an xterm and no window manager. I am typing 'env' in that xterm. This where I'm seeing ENV being different from terminals opened normally. This is the only way I can capture the difference in what env is being passed to X11 versus other shells at the terminal. 

The conditions which give this xterm the correct ENV, are also the same conditions in which problems are absent with my X11 app. This conditions are: either start X11 with 'startx', or add ~/MacOSX/environment.plist.

>> I agree with Jeremy that it is not the best solution, just the only one available now. That file passes its ENV to every launchd process, where I really only need it to be passed to X11.
> 
> Actually, it does *NOT* pass its environment through launchd (on Leopard).

I am using Snow Leopard.

Dave



More information about the Xquartz-dev mailing list