Subject: Re: bug#7923: 23.2; Shell PATH environment variable problem

From: Alan Third <[email-masked]>
Date: Tue, 24 May 2016 19:36:59 +0100

John McHugh <[email-masked]> writes:

> Stefan
>
> I don't think this is the problem
>
> In OS X, Leopard, the initial $PATH setting comes from a property list file
>
> ~/.MacOSX/environment.plist  
>
> This file contains a list of properties and their initial values.  In this case, the properties are environment variables.
> The value for the PATH is 
>
> /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
>
> According to the OS X Leopard documentation, the contents of files in
> /etc/paths.d is then added to PATH. This allows software packages to
> add their specific bin directories without consideration of the
> specific shell to be used, or the user using the machine. Installing
> X11 adds a file to this directory containing the path to X11 binaries.
>
> Now, if I issue the emacs command "shell-command echo $PATH" I get the PATH value that is in the plist file.  If I change the plist file, output of that command changes, as well.
>
> What is not happening is that the additional files in /etc/paths.d are not being added to the path.
>
> Since my shell for shell windows in emacs is bash, my .bashrc file is being executed since, they appear in the PATH echoed from a shell window in emacs.
>
> Is there an explanation of how emacs sets the path for shell commands?

PATH handling on OS X is rather broken and seems to change with each new
release. GUI apps don't inherit the same PATH as terminal applications.
I've found the simplest solution for Emacs is to use the
exec-path-from-shell package.

I wrote up a wee bit about how zsh generates it's PATH on OS X, and it
may give you some pointers for bash:

http://unix.stackexchange.com/questions/246751/how-to-know-why-and-where-the-path-env-variable-is-set/250456#250456

Ultimately this isn't an Emacs problem, but a general issue with OS X,
so I'm going to close this bug report.

Sorry I can't be more help.

-- 
Alan Third