[Xquartz-dev] env variables and launchd problem

Jeremy Huddleston jeremyhu at apple.com
Wed Mar 23 11:44:22 PDT 2011


On Mar 23, 2011, at 10:02, Dave Ray wrote:

> On Mar 23, 2011, at 7:00 AM, Peter Dyballa wrote:
> 
>>>> IMO this should not be necessary, because up to Leopard ~/.MacOSX/ 
>>>> environment.plist is read when you log in. Then all processes  
>>>> inherit this environment. The X clients are a bit different and  
>>>> used to inherit their environment from X11.app ? until recently!
>>> 
>>> Nope.  X11 clients do inherit their environment from X11.app, since  
>>> that's the process that forks and execs them.  That has not changed.
>> 
>> Yes, right! The problem is that X11.app now does not inherit the set  
>> environment and passes something not so useful to the X clients. Which  
>> needs to be corrected. Particularly the manner to set / als current  
>> working directory. $HOME is correct.
> 
> Thank you Peter for being the first on the list to answer my question, after a zillion posts on the topic.

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

> 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 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.

> 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).

--Jeremy



More information about the Xquartz-dev mailing list