From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Barry Fishman Newsgroups: gmane.emacs.help Subject: Re: emacs doesn't inherit PATH from environment Date: Thu, 15 Feb 2018 10:59:41 -0500 Organization: Easynews - www.easynews.com Message-ID: References: <874lmjma7g.fsf@robertthorpeconsulting.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1518713853 19705 195.159.176.226 (15 Feb 2018 16:57:33 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 15 Feb 2018 16:57:33 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Feb 15 17:57:29 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1emMqY-0004Nu-3u for geh-help-gnu-emacs@m.gmane.org; Thu, 15 Feb 2018 17:57:22 +0100 Original-Received: from localhost ([::1]:39441 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emMsY-0005u5-I2 for geh-help-gnu-emacs@m.gmane.org; Thu, 15 Feb 2018 11:59:26 -0500 X-Received: by 10.200.47.98 with SMTP id k31mr2117262qta.37.1518710386644; Thu, 15 Feb 2018 07:59:46 -0800 (PST) Original-Path: usenet.stanford.edu!h20no28673qtm.0!news-out.google.com!e34ni18qtc.0!nntp.google.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!post01.iad!fx43.iad.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Cancel-Lock: sha1:0uXmwYBE8FI4CfRSJhcWb80TmNM= Original-Lines: 95 Original-X-Complaints-To: abuse@easynews.com X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly. X-Received-Bytes: 4688 X-Received-Body-CRC: 689147615 Original-Xref: usenet.stanford.edu gnu.emacs.help:221906 X-Mailman-Approved-At: Thu, 15 Feb 2018 11:58:51 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:116021 Archived-At: 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