all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Barry Fishman <barry@ecubist.org>
To: help-gnu-emacs@gnu.org
Subject: Re: emacs doesn't inherit PATH from environment
Date: Thu, 15 Feb 2018 10:59:41 -0500	[thread overview]
Message-ID: <m3r2pmfdle.fsf@ecube.ecubist.org> (raw)
In-Reply-To: mailman.9140.1518662330.27995.help-gnu-emacs@gnu.org


On 2018-02-14 19:38:42 -07, Bob Proulx wrote:
> Larry Evans wrote:
>> Indeed, the setenv in ~/.emacs.d/init.common.el was deleted, but I
>> also moved the 'export PATH' from ~/.bashrc to ~/.profile. After
>> that, the Makefile worked.

Note, this is not always the case.  Commonly desktop environments just
do the /etc/profile and not any login specific shell setup like
"~/.profile".  KDE has a configuration window option to set up your
environment.

>
> Sounds good.  In my world view the best and only place to set PATH is
> in the .profile and not elsewhere.
>
> So glad to hear from you that things are working in the normal
> configuration.  That's great.
>
>> The conclusion I reached was that somehow emacs, when invoked from
>> my windows interface, apparently just runs the ~/.profile code but
>> not the ~./bashrc code and that's why emacs was not seeing the PATH
>> (because, previously it was set in ~/.bashrc).

> However, and this is a big *HOWEVER*, along came Desktop Environments
> such as GNOME, KDE, LXDE, XFCE, and others running an "xdm" or X
> Display Manager such as lightdm and others.  For some reason
> unfathomable to me they decided not to set up the originating shell as
> a login shell!  That is really a shock to me.  And one that has caused
> problems for literally decades.
>
> ...
>
> IMNHO the only sane thing to do in the ~/.xsessionrc file is to source
> the $HOME/.profile file.  They are both portable shell syntax files.
> Then put all of your environment setting in ~/.profile the same as
> always.  Otherwise one ends up with some things set one way when
> logging in with ssh and some things set another way when logging in
> with a graphical login manager.  In ~/.xsessionrc file:
>
>   . "$HOME/.profile"
>
> [[There is also the ~/.xsession script.  I used to use and recommend
> that way for years.  But I have been convinced by others that it is
> better to recommend the ~/.xsessionrc file instead.  It is less for
> people to understand using that file.]]

This does not work very well for me.  In particular, I find most of my
systems now use Wayland, so I'm not sure .xsession* files are
meaningful.  Even under X, various distributions may not reference the
~/.sessionrc file in the session startup scripts, although I used to add
it to systems without it.  Recently I just gave up.

There seems to be a conflict between the freedesktop people and the
shell maintainers on how things should be setup, and the user is left in
the crossfire.  There is now even a pam_env.so specific
"~/.pam_environment" method (with a whole new vaguely defined file
format) which sometimes works (but not always).

Personally I find myself brute forcing, and adding a zz-path.sh to
/etc/profile.d so it gets called last (and doesn't get replaced in
system updates) and just does:

if [ -f "${HOME}/.config/paths.sh" ]; then
  . "${HOME}/.config/paths.sh"
fi

And have my ~/.config/paths.sh file setup just environment information I
need for applications launched via the desktop, such as fixing PATH.

My ~/.bashrc is a link to my ~/.profile, which does the right thing
based on its own determination of if my environment has already been set
or if it is an interactive shell.

I start it with:

--8<---------------cut here---------------start------------->8---
if [ -z "$BASH" ]; then
    complete () {
      :
    }
    shopt () {
      false
    }
fi
--8<---------------cut here---------------end--------------->8---

To disable my bash specific parts when some other shell is invoked.

Emacs is still left with resolving things like where to find info
directories, but doesn't have to deal with fixing the environment.

[Rant about the freedesktop's ideas left for a more appropriate time/group]
--
Barry Fishman


  parent reply	other threads:[~2018-02-15 15:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-12 15:51 emacs doesn't inherit PATH from environment Larry Evans
2018-02-14  1:27 ` Glenn Morris
2018-02-14  2:24   ` Larry Evans
2018-02-14 14:53     ` Larry Evans
2018-02-14 23:18       ` Robert Thorpe
2018-02-15  1:03         ` Larry Evans
2018-02-15  2:38           ` Bob Proulx
     [not found]           ` <mailman.9140.1518662330.27995.help-gnu-emacs@gnu.org>
2018-02-15 15:59             ` Barry Fishman [this message]
2018-02-15 20:18               ` Bob Proulx
     [not found]         ` <mailman.9127.1518652911.27995.help-gnu-emacs@gnu.org>
2018-02-16 16:58           ` Emanuel Berg
     [not found]     ` <mailman.9096.1518616283.27995.help-gnu-emacs@gnu.org>
2018-02-16 16:54       ` Emanuel Berg
     [not found] ` <mailman.9075.1518571658.27995.help-gnu-emacs@gnu.org>
2018-02-14  1:38   ` Emanuel Berg
     [not found] <mailman.8985.1518453550.27995.help-gnu-emacs@gnu.org>
2018-02-13 19:12 ` Emanuel Berg
2018-02-13 23:57   ` Larry Evans
     [not found]   ` <mailman.9069.1518566292.27995.help-gnu-emacs@gnu.org>
2018-02-14  0:11     ` Emanuel Berg
2018-02-14  0:48       ` Larry Evans
2018-02-14  1:45         ` Robert Thorpe
2018-02-14  2:35           ` Larry Evans
     [not found]       ` <mailman.9071.1518569365.27995.help-gnu-emacs@gnu.org>
2018-02-14  1:23         ` Emanuel Berg
2018-02-14  1:25         ` Emanuel Berg
2018-02-14  1:32   ` Robert Thorpe
2018-02-14 19:19   ` Bastian Beischer
     [not found]   ` <mailman.9115.1518635972.27995.help-gnu-emacs@gnu.org>
2018-02-16 17:14     ` Emanuel Berg
     [not found] <mailman.9076.1518571984.27995.help-gnu-emacs@gnu.org>
2018-02-14  1:43 ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3r2pmfdle.fsf@ecube.ecubist.org \
    --to=barry@ecubist.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.