How does the shell environment load when logging in graphically?

I've found that when logging in graphically the shell loading process works differently than logging in through the console. Environment variables such as $BASH_VERSION and $ZSH_VERSION are not set when logging in graphically, and a script specifically written for bash and zsh that I tried to use while logging in causes the login process to restart and returns me to the login prompt (which stops me from logging in while this script is in place), when logging in through the console the same setup works fine though.

In this chruby-thread on github I talk about the case where I am experiencing the issue. Is the shell loading process working as it should when logging in graphically, and if so is there any documentation on how it works (and if so, where can I find it)? How should I make this work?


If you start a X11 session, the ~/.profile and similar files are not sourced.

If you want to enforce this, create a file /etc/X11/Xsession.d/95-enforce-profile with the following content:

    # This file is sourced by Xsession(5), not executed.
    # source user profile
    if test -e ~/.bash_profile
    then
        . ~/.bash_profile
    else
        [ -e ~/.profile ] && . ~/.profile
    fi