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

Re: No sourcing of ~/.profile at login



Paul Smith wrote:
> Daniel B. writes:
>   db> Paul Smith wrote:
>   >> .. If you're using a graphical login manager like GDM or
>   >> XDM, then these methods of login never actually invoke a login shell,
>   db> Why not?  (Why shouldn't logging in via GDM execute your
>   db> login-time shell initialization?)
> 
> I don't know, for sure, but that's the way it works and has always
> worked (not just in Debian).

None of this is Debian specific.

When you log in at a graphics console the profile is not sourced.  The
Xsession script uses /bin/sh and does not know what shell you will be
using.  To set PATH at the graphical login you should put it in your
$HOME/.xsession file.  Here is one example.

  #!/bin/sh
  export PATH=$HOME/bin:$PATH:.
  exec x-session-manager # Or exec fvwm, or exec olvwm, or ...

Don't forget to:

  chmod a+x ~/.xsession

Remember you have to log in using [default] and not [gnome] or
whatever at the graphical login screen.  If you log in with a specific
window manager chosen then that forces the system values and avoids
your user specified ones.  That is the way to tell if a bug is yours
in your environment scripts or a bug with the selected window manager.
In this case [default] means your .xsession environment or the
system's if you don't have one.

Here is the hint key:

  ~/.profile    # character terminal login (or .bash_profile / .zprofile)
  ~/.xsession   # X11 graphical login

Most people will want both.

> I agree that it seems logical that the shell that the display
> manager invokes should be marked as a login shell... but it doesn't.
>
> What I do instead is find the X setup file (depending on what you're
> running this might be ~/.xsession, ~/.gnomerc, etc.) and source the
> profile explicitly.

That works and doesn't work depending upon exactly what you put in
your .profile.  As long as you only use /bin/sh compatible syntax you
are fine.  But if you use something specific to your non-/bin/sh
personal shell then you will fail to log in.

Why doesn't Xsession load .profile directly?  /bin/sh is used by
Xsession to start up your environment.  If you are a bash user and
source /etc/bash_completions in your .bash_profile then /bin/sh would
have syntax errors trying to read it and you would be logged out.
Instead you need a personality file that is guarenteed to be /bin/sh
compatible regardless of your own personal shell environment.

Basically if Xsession did load $HOME/.profile then any errors there
would prevent the login from happening.  I am sure the Gnome/KDE folks
just got too tired of seeing bogus bug reports about gdm/kdm not being
able to log people in and avoided this by this process.  After having
walked through the process of learning this I agree with the choices.
But I know they were unknown to me when I started looking at what was
happening.

Bob

References:

  http://www.kde.org/documentation/faq/configure.html#id2913380

    "9.7.  KDE (kdm) does not read my .bash_profile!".

    The login managersxdm and kdm do not run a login shell, so
    .profile, .bash_profile, etc. are not sourced.  When the user logs
    in, xdm runs Xstartup as root and then Xsession as user.  So the
    normal practice is to add statements in Xsession to source the
    user profile.  Please edit your Xsession and .xsession files.

Attachment: pgpvhOaDwhIkb.pgp
Description: PGP signature


Reply to: