help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs doesn't inherit PATH from environment


From: Bastian Beischer
Subject: Re: emacs doesn't inherit PATH from environment
Date: Wed, 14 Feb 2018 20:19:24 +0100

Hello Emanuel,

On Tue, Feb 13, 2018 at 8:12 PM, Emanuel Berg <moasen@zoho.com> wrote:
>
> Larry Evans wrote:
>
> > When executing a Makefile or invoking eshell,
> > the PATH is not the same as when running from
> > a terminal window. Even when I modify the
> > PATH in the emacs initialization code in
> > ~/emacs.d/init.common.el, the executables in
> > the PATH are *not* found.
>
> Where and how do you set PATH?
>
> Shell stuff that I want available from Emacs
> I have to set in a special file for zsh, which
> is
>
>     ~/.zshenv
>
> If I put the same thing in plain .zshrc or
> a file loaded from there, it doesn't work!
>
> I never understood why because the Emacs
> instance is run from a zsh shell, but for some
> reason Emacs cannot see zsh stuff that aren't
> defined in that special file, even when (as
> said) executed from a point which HAS access to
> it all!
>
> My experience with this has only been
> *functions*, not environmentals, but it is
> worth a shot.

There is a key difference between functions and variables. In zsh
functions are not exported to subshells (except for (...) subshells),
unlike exported variables. In bash you can mark functions with
'typeset -fx' to propagate them to subshells, but I think with zsh
that's not possible and you need to redefine them in a shell startup
file which is read when the subshell is spawned. Typically these
subshells are 'interactive non-login' shells so possible places are
~/.zshrc and ~/.zshenv, but not ~/.zprofile. ~/.zshenv is always read,
also in non-interactive scripts, which is why I don't like to use it.
It is also possible to place the code for the function in a separate
file in $FPATH and use autoloads, but even that does not work without
the autoload line in ~/.zshrc or ~/.zshenv for subshells.

For variables none of this should matter: As long as the variable is
exported it should be visible in the subshell. However, I don't think
'eshell' is a real shell, so that may be a different story.

>
> Also, you can use this to check the value prior
> to starting the shell and Makefile compilation
> session:
>
>     (getenv "PATH")
>
> Is it correct?
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573



reply via email to

[Prev in Thread] Current Thread [Next in Thread]