From: Tim X <timx@nospam.dev.null>
To: help-gnu-emacs@gnu.org
Subject: Re: Problems starting emacs with correct environmental settings
Date: Sat, 04 Jul 2009 10:42:35 +1000 [thread overview]
Message-ID: <87ws6p5ldw.fsf@lion.rapttech.com.au> (raw)
In-Reply-To: mailman.1742.1246619589.2239.help-gnu-emacs@gnu.org
Peter Dyballa <Peter_Dyballa@Web.DE> writes:
> Am 03.07.2009 um 12:08 schrieb Pascal J. Bourguignon:
>
>> Depending on the shell used by these scripts, you may edit one of the
>> file used by these shell to set the environment. Eg. in case of bash,
>> you could set your environment in ~/.bash_env or ~/.bash_login or
>> ~/.bashrc ; for other Bourne shells, ~/.profile or ~/.login could be
>> used. In the last resort, you can directly edit the X startup scrip
>> that is used in your configuration.
>
>
> Alain send me some answers privately. To me it seems that processes created
> from the menu icons inherit only a small environment, could be that of a
> privileged process. It obviously has some basic components in PATH, but
> not Alain's private parts. And GNU Emacs actually is opened via
> emacsclient, from a shell script, which is passed to the launcher as "
> ~/..." and "~/" does not get expanded to something like "/home/<user>/..."
>
> With pstree, observing such a launched process, one might find some basic
> clues. By using a shell script that creates a login shell to launch
> emacsclient from inside it a few problems could be cured…
>
> --
> Greetings
>
Note that I'm speaking about accessing X from gdm/xdm/etc rather than
starting it with something like startx.
On modern Linux boxes, the scripts that start X do so in a non-login
shell. This means files like .bash_profile are not sourced. The X
session is normally run as the last stage in the startup process - often
the last line is something like
exec <window manager>
which makes the current running process your X window manager
process. When you kill that process, you are logged out.
The limitation of this approach is that your X window manager process
does not have all the environment settings that you would normally see
in a standard login shell. When the window manager forks another process
to launch something like emacs, it passes on its environment variables,
but as its not a login shell and .bash_profile has not been sourced, the
envrionment is somewhat limited.
There are a number of solutions you can use.
1. In the case of GDM, edit /etc/gdm/Xsession and make it either run as
a login shell or have it source your .bash_profile etc.
2. Write a shell wrapper script which sources your environment scripts
and use it to launch programs from menus/icons etc.
3. Start an xterm witht he -ls switches so that it starts as a login
shell and execute the programs from there.
4. You can set some environment settings in the /etc/environment file,
but note that all processes source this file, including processes that
are not started by a specific user.
I use to change the first line of the Xsession script so that it runs as
a login shell and then I have all my environment settings. However, I
stopped doing that because everytime GDM was updated, I'd lose my
changes if the update included a new Xsession script.
Now, I place settings that are common to all users/processes in
/etc/environment and I have a basic 'launcher' script that sources my
.bash_profile before starting a program like emacs. I use this script in
place of the standard things for opening an xterm or starting emacs.
HTH
Tim
--
tcross (at) rapttech dot com dot au
next prev parent reply other threads:[~2009-07-04 0:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.1714.1246572018.2239.help-gnu-emacs@gnu.org>
2009-07-02 22:45 ` Problems starting emacs with correct environmental settings Pascal J. Bourguignon
2009-07-04 22:01 ` Johan Bockgård
[not found] ` <mailman.1831.1246744930.2239.help-gnu-emacs@gnu.org>
2009-07-04 23:39 ` Pascal J. Bourguignon
2009-07-03 10:08 ` Pascal J. Bourguignon
2009-07-03 11:12 ` Peter Dyballa
[not found] ` <mailman.1742.1246619589.2239.help-gnu-emacs@gnu.org>
2009-07-04 0:42 ` Tim X [this message]
2009-07-02 19:22 Alain Muls
2009-07-02 23:05 ` Peter Dyballa
2009-07-02 23:11 ` Jeff Clough
2009-07-02 23:14 ` Jeff Clough
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=87ws6p5ldw.fsf@lion.rapttech.com.au \
--to=timx@nospam.dev.null \
--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.