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

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 24 May 2016 18:38:02 +0000

Your bug report

#7923: 23.2; Shell PATH environment variable problem

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
7923: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7923
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#7923: 23.2; Shell PATH environment variable problem
From: Alan Third <[email-masked]>
To: John McHugh <[email-masked]>
Cc: Stefan Monnier <[email-masked]>, [email-masked]
Date: Tue, 24 May 2016 19:36:59 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

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

Subject: 23.2; Shell PATH environment variable problem
From: John McHugh <[email-masked]>
To: [email-masked]
Date: Wed, 26 Jan 2011 16:34:51 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

From: John McHugh <[email-masked]>

This seems to be specific to OS X Leopard

I use bash as my emacs shell. I loaded 23.2.1 yesterday using
"homebrew", replacing an earlier version from macports which I
removed. along with a large number of applications.  I reinstalled TeX
from MacTeX-2010.  I noticed that tex programs were in the PATH in a
terminal shell, but not in an emacs shell.  Ultimately, I discovered
that the new TeX install had added a file with the path for TeX binaries
to /etc/paths.d/ and that none of the paths from these files were in the
PATH for the emacs shell but they were in the path for terminal shells.

As far as I can tell, emacs is obtaining the default PATH from
~/.MacOSX/environment.plist and then executing my .bashrc (or .profile
which is identical), but is not invoking the /etc/profile nor is it
calling "/usr/libexec/path_helper -s" which augments the defaults and is
called in /etc/profile.

My workaround is to create a .emacs_bash file which contains the line

eval `/usr/libexec/path_helper -s`

This provides the correct path at the minor expense of two command
prompts on the first line of the resulting shell buffer.

John McHugh

===========

In GNU Emacs 23.2.1 (x86_64-apple-darwin10.6.0, NS apple-appkit-1038.35)
 of 2011-01-25 on John-McHughs-MacBook-Pro.local
Windowing system distributor `Apple', version 10.3.1038
configured using `configure  '--prefix=/usr/local/Cellar/emacs/23.2' '--without-dbus' '--enable-locallisppath=/usr/local/share/emacs/site-lisp' '--infodir=/usr/local/Cellar/emacs/23.2/share/info/emacs' '--with-ns' '--disable-ns-self-contained' 'CC=/usr/bin/cc' 'CFLAGS=-O3 -w -pipe''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  shell-dirtrack-mode: t
  display-time-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<mouse-1> C-x b * s c r <tab> <return> M-v C-y <help-echo> 
<help-echo> <down-mouse-1> <mouse-1> <down-mouse-1> 
<mouse-1> M-x c o m p a r e SPC w SPC <return> <down-mouse-1> 
<mouse-1> <help-echo> <down-mouse-1> <mouse-1> C-x 
b p r <tab> <backspace> <backspace> . e m a <tab> <backspace> 
<backspace> <backspace> C-g g C-x C-r . e m a <tab> 
b <tab> <backspace> _ <tab> <return> <help-echo> <help-echo> 
<help-echo> <help-echo> <down-mouse-1> <mouse-movement> 
<mouse-movement> <drag-mouse-1> <down-mouse-1> <mouse-movement> 
<mouse-movement> <drag-mouse-1> <help-echo> <down-mouse-1> 
<mouse-1> C-y <return> e c h o SPC $ P A T H <return> 
<help-echo> <help-echo> <down-mouse-1> <mouse-1> C-x 
b <return> <down-mouse-1> <mouse-1> <help-echo> <down-mouse-1> 
<mouse-1> M-x c o m p a r e SPC w SPC <return> <help-echo> 
<help-echo> <down-mouse-1> <help-echo> <mouse-movement> 
<mouse-movement> <drag-mouse-1> <help-echo> <down-mouse-1> 
<mouse-1> C-x b <return> <up> <up> C-k C-x C-q C-a 
C-k C-k C-d C-x C-s <help-echo> C-o e c h o SPC f o 
o <down-mouse-1> <wheel-up> <drag-mouse-1> e c h o 
SPC b a r <return> C-x C-s <help-echo> <down-mouse-1> 
<mouse-1> C-x j C-x k <return> y e s <return> <backspace> 
M-x s h e k k <backspace> <backspace> l l <return> 
e c h o SPC $ P A T H <return> <help-echo> <down-mouse-1> 
<mouse-1> C-x b <return> <down-mouse-1> <mouse-1> <help-echo> 
<down-mouse-1> <mouse-1> M-x c o m p a r e SPC w SPC 
<return> <down-mouse-1> <mouse-1> C-x b <return> <up> 
<up> <up> C-k C-k <down> C-k C-k C-x C-s <down-mouse-1> 
<mouse-1> C-x k <return> y e s <return> M-x s h e l 
l <return> <return> e c h o SPC $ P A T H <return> 
<down-mouse-1> <mouse-1> <down-mouse-1> <mouse-1> C-x 
b <return> <up> <up> <up> M-x c o m p a r e SPC w SPC 
<return> <help-echo> M-x r e p o r t - e m <tab> <
return>

Recent messages:
Saving file /Users/mchugh/.emacs_bash...
Wrote /Users/mchugh/.emacs_bash
byte-code: Beginning of buffer
Mark set
Saving file /Users/mchugh/.emacs_bash...
Wrote /Users/mchugh/.emacs_bash
Mark set
Saving file /Users/mchugh/.emacs_bash...
Wrote /Users/mchugh/.emacs_bash
Mark set

Load-path shadows:
None found.

Features:
(shadow sort mail-extr message ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils mailheader canlock sha1 hex-util
hashcash mail-utils emacsbug compare-w multi-isearch dired-aux dired
regexp-opt cus-edit wid-edit pp help-mode view apropos help-fns
ansi-color shell comint ring time cus-start cus-load tooltip ediff-hook
vc-hooks lisp-float-type mwheel ns-win easymenu tool-bar dnd fontset
image fringe lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev loaddefs button minibuffer faces cus-face files
text-properties overlay md5 base64 format env code-pages mule custom
widget hashtable-print-readable backquote make-network-process ns
multi-tty emacs)