Closed ghost closed 4 years ago
This behaviour makes sense if you read the package description: it reproduces inside Emacs exactly the $PATH
that you would see in your shell. The package does not "remove" the internal Emacs path from exec-path
so much as simply replace exec-path
wholesale.
Does this actually cause a problem for you? If so, I'm sure there would be ways to work around it, e.g. add exec-directory
or similar to exec-path
after calling exec-path-from-shell-initialize
.
But the /Applications/MacPorts/Emacs.app/Contents/MacOS/libexec/ component that is left in the exec-path is not in $PATH
It's the small inconsistency between the /Applications/MacPorts/Emacs.app/Contents/MacOS/libexec and /Applications/MacPorts/Emacs.app/Contents/MacOS/bin components I'm trying to understand.
Here's what I'd expect: when you start up Emacs, it adds both the 'libexec' and 'bin' directories to the PATH. Then when you run exec-path-from-shell
, both are removed, because exec-path
is replaced with directories in the shell's $PATH
, which naturally won't include the Emacs libexec
and bin
paths. It sounds like that's exactly what's happening for you, and I'm not quite clear whether that answers your last comment.
"Then when you run exec-path-from-shell, both are removed", yes, this is what I was expecting from the package documentation.
However the "/Applications/MacPorts/Emacs.app/Contents/MacOS/libexec/" component is not removed from exec-path
by the call to exec-path-from-shell-initialize
That's probably down to your shell config files: when the shell is "exec"-d and asked to print out its path, the shell process inherits Emacs' "PATH" variable. So if your shell config makes some assumptions about the existing value of $PATH
, and looks like PATH=/some/extra/path:$PATH
rather than PATH=/some/extra/path:/bin:/usr/bin
or similar, then this is the behaviour you'll see. I'm wary of explicitly blanking out PATH
before calling the shell, because it would cause more breakage and unexpected behaviour to do so.
When starting Emacs:
$PATH = "/usr/bin:/bin:/usr/sbin:/sbin" exec-path = "/usr/bin" "/bin" "/usr/sbin" "/sbin" "/Applications/MacPorts/Emacs.app/Contents/MacOS/libexec" "/Applications/MacPorts/Emacs.app/Contents/MacOS/bin"
After running exec-path-from-shell-initialize:
$PATH = "/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin" exec-path = "/opt/local/bin/" "/opt/local/sbin/" "/Library/Frameworks/Python.framework/Versions/3.7/bin/" "/usr/local/bin/" "/usr/bin/" "/bin/" "/usr/sbin/" "/sbin/" "/Library/TeX/texbin/" "/opt/X11/bin/" "/Applications/MacPorts/Emacs.app/Contents/MacOS/libexec/"
So the "/Applications/MacPorts/Emacs.app/Contents/MacOS/bin" component that is added to exec-path during Emacs start-up is removed by the exec-path-from-shell package.
Is this the expected default behaviour? What is the rational for the package removing it from exec-path?
Emacs is the Emacs.app from MacPorts, the package version is 20180323.1904 from MELPA, macOS 10.13.6