6

Emacs 24.5.1 on OS X 10.11.1.

This is the content of /etc/paths:

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

This is the value of exec-path:

("/usr/bin"
 "/bin"
 "/usr/sbin"
 "/sbin" "/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9" 
 "/Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_9" 
 "/Applications/Emacs.app/Contents/MacOS/libexec" 
 "/Applications/Emacs.app/Contents/MacOS/bin")

Why doesn't it contain /usr/local/bin?

4

OS X only evaluates /etc/paths and /etc/paths.d/ for shell sessions, through an invocation of path_helper in the global shell profile.

GUI applications have a different launch path (through launchd as far as I know), which includes a different environment and a different environment configuration. Specifically, GUI applications do not inherit $PATH from a shell session, and thus do not get $PATH entries from the aforementioned files.

You can work around this behaviour with exec-path-from-shell, which sets exec-path based on the $PATH value of a shell session. This package is more or less a standard equipment for Emacs users on OS X.

1
  • My memory is wrong. I know $PATH is only for shell but thought etc/paths is for all.
    – an0
    Nov 12 '15 at 13:34
1

For future searchers: I used this to solve the problem:

https://github.com/arouanet/path-helper

It is a small elisp module that mimics the behavior of the /usr/libexec/path_helper utility available on MacOS.

I added these lines to my .emacs

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; set path correctly on MacOS, based on /etc/paths
(if (memq window-system '(ns mac))
  (path-helper-setenv "PATH"))

For more information you may want to examine this link on emacswiki.

-1

Emacs initializes ‘exec-path’ when it starts up, based on the value of the environment variable ‘PATH’.

C-hig (elisp) Subprocess Creation RET

4
  • I think the OP's question is rather, why the contents of this file do not end up in $PATH for an Emacs session, like they do for a shell session.
    – user227
    Nov 12 '15 at 8:34
  • No doubt you're right. This answer would at least have enabled them to realise what the real question actually was, though. I would suggest to whoever cast the down-vote that voting down an answer which does answer the stated question is perhaps a little bit harsh.
    – phils
    Nov 12 '15 at 9:25
  • I cast the down vote because I think that this does not answer the question at all. It's entirely unrelated to the actual issue. Besides, in my opinion just quoting the manual with no context is not a proper answer.
    – user227
    Nov 12 '15 at 9:47
  • They appeared to be confused about where the contents of exec-path came from, and believed that their /etc/paths file had something to do with it. I quoted the manual to show that this file has nothing to do with exec-path (and they would have then been able to easily confirm that Emacs does indeed use the value of PATH). I'm unsure as to what additional context I could have usefully provided. (I could have stated explicitly that the quote therefore meant that the value did not come from /etc/paths, but that would have seemed a bit redundant.)
    – phils
    Nov 12 '15 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.