PATH environment variable incorrectly set from launchd configuration file in 10.10

Number:rdar://18945659 Date Originated:10/11/2014
Status:Open Resolved:
Product:OSX Product Version:10.10 / 14A389
Classification: Reproducible:Always
In past versions of OSX, setting PATH was effective from the EnvironmentVariables section of a launchd plist configuration script.

In 10.10, setting PATH from EnvironmentVariables appears to result in the path being set twice, so that there are two "PATH" environment variables (as shown for example by a ruby script - see below). 

This results in the PATH EnvironmentVariable setting being ignored by - for example - Python scripts (see below).

Steps to Reproduce:
To run example launchd configuration script and review output environment variables:

cp envvars.plist py_env_out /tmp
cd /tmp
rm -rf /tmp/*env_vars && launchctl load envvars.plist && sleep 1 && launchctl unload envvars.plist && cat /tmp/*env_vars

The envvars.plist script uses EnvironmentVariables to set the PATH to:

PATH : /a/funny/path:/bin:/usr/bin:/usr/sbin:/sbin

The script then runs a trivial Python file to print out the environment variables.

Expected Results:
On OSX 10.9 the output of the commands above is:

PATH : /a/funny/path:/bin:/usr/bin:/usr/sbin:/sbin
ANOTHER_VAR : some value

This is what I was expecting. 

If I edit envvars.plist to run a ruby file to print out the environment variables:


Then I get this output, also expected:

PATH : /a/funny/path:/bin:/usr/bin:/usr/sbin:/sbin
ANOTHER_VAR : some value

Actual Results:
On OSX 10.10, the output is:

XPC_SERVICE_NAME : edu.berkeley.envvars
PATH : /usr/bin:/bin:/usr/sbin:/sbin
ANOTHER_VAR : some value

Note that ANOTHER_VAR is correctly set, but the PATH is not correctly set.

Running the ruby program to output the environment variables (see above), I get this:

PATH : /usr/bin:/bin:/usr/sbin:/sbin
ANOTHER_VAR : some value
PATH : /a/funny/path:/bin:/usr/bin:/usr/sbin:/sbin
XPC_SERVICE_NAME : edu.berkeley.envvars

Note there are two "PATH" variables here, one that appears to be the default, and the other from EnvironmentVariables.

If I switch to a bash program to output the environment variables:


Then the PATH is echoed as expected.

bash-4.3# cat envvars.plist 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN>
<plist version="1.0">

            <string>some value</string>
bash-4.3# cat py_env_out 
#!/usr/bin/env python
import os

with open('/tmp/py_env_vars', 'wt') as fobj:
    for key, value in os.environ.items():
        fobj.write('{0} : {1}\n'.format(key, value))
bash-4.3# cat rb_env_out 
#!/usr/bin/env ruby'/tmp/rb_env_vars', 'w') { |file|
    ENV.each do |k,v|
       file.write("#{k} : #{v}\n")


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!