2

The GNU elisp documentation states:

"Generally, you should not modify exec-path directly. Instead, ensure that your PATH environment variable is set appropriately before starting Emacs. Trying to modify exec-path independently of PATH can lead to confusing results."

Given that it is not, in general, possible to ensure the path is correctly set before launching emacs (macOS GUI v's terminal being my case of interest), is it possible to modify the PATH variable from my .emacs, and then have Emacs regerenate the exec-path variable as is done during start-up?

Edited after comment from @lawlist

Using the exec-path-from-shell I observe the following behaviour:

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 expected? What is the rational for the package removing it from exec-path?

Andy
  • 21
  • 4
  • 3
    See: https://github.com/purcell/exec-path-from-shell – lawlist Jul 24 '18 at 18:01
  • You can modify any env var from Emacs, using command `setenv`. – Drew Jul 24 '18 at 18:26
  • Thank you @Drew, I have a small .el file I'm using to build the PATH vairable using setenv, it is getting it from $PATH to exec-path I'm confused by. – Andy Jul 24 '18 at 19:34
  • @lawlist, Hi, I've been playing with the exec-path-from-shell package, but I do not understand it's behaviour. I have edited my question to list the bits I don't understand in it's behaviour. – Andy Jul 24 '18 at 19:49
  • I cannot speak for Steve Purcell, but if you would like help modifying the behavior of the library, then you can either ask a question here regarding how to do that, and/or you can ask Mr. Purcell to address that issue by opening an "Issue" on Github. To make it relevant, you might add something to the effect of wanting to use some of the executables in the `bin` directory from within Emacs. – lawlist Jul 24 '18 at 20:31
  • @lawlist, Thank you for your follow-up, I'm going to raise an issue on GitHub for the behaviour of the package, to see if it's a bug, or by design. However, the first part of the question still stands, at some point during Emacs start-up $PATH (and possibly other things) are used to construct the initial exec-path, is it possible to set $PATH (via setenv), and rerun the interesting components of Emacs start-up to obtain a new exec-path? – Andy Jul 24 '18 at 21:10

0 Answers0