It looks like environment variables set in .bash_profile are visible to applications started in gnome but not via a shell. For example evolution knows when I modify LC_COLLATE.
But how? Here's the invocation chain from login down to evolution -- no shells here.
1710 ? Ss 0:00 /usr/sbin/gdm-binary -nodaemon 14284 ? S 0:00 _ /usr/libexec/gdm-simple-slave --display-id /org/gnome/Disp 14285 tty7 Ss+ 0:43 _ /usr/bin/Xorg :0 -br -verbose -auth /var/run/gdm/auth- 14366 ? S 0:00 _ pam: gdm-password 14413 ? Ssl 0:00 _ gnome-session 14523 ? Sl 0:00 _ metacity 14536 ? S 0:00 _ gnome-panel 14537 ? S 0:00 _ nautilus 14542 ? S 0:00 _ /bin/sh /usr/lib64/firefox-3.5.4/run-mozilla.s 14651 ? Sl 0:41 | _ /usr/lib64/firefox-3.5.4/firefox 14543 ? Sl 0:17 _ evolution
What am I missing?
Thanks - jon
Jonathan Ryshpan wrote:
It looks like environment variables set in .bash_profile are visible to applications started in gnome but not via a shell. For example evolution knows when I modify LC_COLLATE.
It depends on the type of shell. Only a login shell reads .bash_profile. If you are starting a (x)terminal, and launching the program from there, the default is not to run your as a login shell.
Mikkel
On Sun, Nov 1, 2009 at 8:04 AM, Mikkel mikkel@infinity-ltd.com wrote:
Jonathan Ryshpan wrote:
It looks like environment variables set in .bash_profile are visible to applications started in gnome but not via a shell. For example evolution knows when I modify LC_COLLATE.
It depends on the type of shell. Only a login shell reads .bash_profile. If you are starting a (x)terminal, and launching the program from there, the default is not to run your as a login shell.
Stuff that you need defined irrespective of the type of shell should go in ~/.bashrc
Didar
On Sun, Nov 1, 2009 at 1:57 PM, Didar Hossain didar.hossain@gmail.com wrote:
On Sun, Nov 1, 2009 at 8:04 AM, Mikkel mikkel@infinity-ltd.com wrote:
Jonathan Ryshpan wrote:
It looks like environment variables set in .bash_profile are visible to applications started in gnome but not via a shell. For example evolution knows when I modify LC_COLLATE.
It depends on the type of shell. Only a login shell reads .bash_profile. If you are starting a (x)terminal, and launching the program from there, the default is not to run your as a login shell.
Stuff that you need defined irrespective of the type of shell should go in ~/.bashrc
Correction: ~/.bashrc is for non-login shells *only*. So, you will need to put the stuff in both ~/.bashrc and ~/.bash_profile
Didar
On Sunday 01 November 2009 01:31 AM, Didar Hossain wrote:
On Sun, Nov 1, 2009 at 1:57 PM, Didar Hossaindidar.hossain@gmail.com wrote:
Stuff that you need defined irrespective of the type of shell should go in ~/.bashrc
Correction: ~/.bashrc is for non-login shells *only*. So, you will need to put the stuff in both ~/.bashrc and ~/.bash_profile
... or put this in your .bash_profile and have everything in your .bashrc ;)
if [ -f ~/.bashrc ]; then . ~/.bashrc fi
Didar
On 10/31/09 03:39, quoth Jonathan Ryshpan:
It looks like environment variables set in .bash_profile are visible to applications started in gnome but not via a shell. For example evolution knows when I modify LC_COLLATE.
But how? Here's the invocation chain from login down to evolution -- no shells here.
This is an old and stupid problem. When you log in you should have your environment fully defined. The environment is basically all of your environment variables. They should all be defined in exactly one place: Your ~/.bash_profile and nowhere else.
I run kde so I can't tell you what I would do to fix it. I log in and my environment is defined because kde actually works.
If you log in using gdm and your environment is not defined then my advise is not going to be pretty.
1. You can file a bug. I encourage this. It is broken behavior and should be fixed.
Option B. Start debugging the problem. The idea is to start putting echo statements in your /etc/profile and your ~/.bash_profile with the goal of creating a new file in /etc/X11/xinit.d to see where you can source in your /etc/profile followed by sourcing in your ~/.bash_profile. You should append to a logfile in /tmp and make sure to delete the file before logging out.
echo "$(date): Hello from /etc/profile" >> /tmp/login
You might be able to say something simple in /etc/X11/xinit/xinitrc-common like
f=/etc/profile [[ -f $f ]] && . $f f=~/.bash_profile [[ -f $f ]] && . $f
IT IS WRONG to set environment variables in your .bashrc unless you really know what you're doing. Most people don't. IT IS WRONG to have to run a terminal emulator program with the idea that it should be a login shell. ALL PROGRAMS use the environment, not just terminal emulators. If you log in then your environment should be defined.
I don't use gnome but I'm very surprised that this is still an issue.
Hi Steven,
On Sunday 01 November 2009 09:32 PM, Steven W. Orr wrote:
On 10/31/09 03:39, quoth Jonathan Ryshpan:
IT IS WRONG to set environment variables in your .bashrc unless you really know what you're doing. Most people don't. IT IS WRONG to have to run a terminal emulator program with the idea that it should be a login shell. ALL PROGRAMS use the environment, not just terminal emulators. If you log in then your environment should be defined.
What is your comment on the method I posted, have your .bash_profile source your .bashrc ? That way you have a consistent environment every time, irrespective of whether I am at an xterm or VT or simply running some GUI app from a menu or icon. (I am of course assuming my desktop environment sources my .bash_profile, as it should, when I login :) )
Would you say that is a proper way to do things?
On Sat, 2009-10-31 at 21:34 -0500, Mikkel wrote:
Jonathan Ryshpan wrote:
It looks like environment variables set in .bash_profile are visible to applications started in gnome but not via a shell. For example evolution knows when I modify LC_COLLATE.
It depends on the type of shell. Only a login shell reads .bash_profile. If you are starting a (x)terminal, and launching the program from there, the default is not to run your as a login shell.
Thanks to all for your advice on this. However I have a *question* and not a *problem*. I have LC_COLLATE=POSIX in .bash_profile and not in .bashrc, and everything is working just as I would like it to. If I find problems in the future, I may move it into .bashrc, which is invoked from .bash_profile, in exactly the way that Suvayu Ali recommended; this method is in the standard .bash_profile located in /etc/skel.
My *question* is what process is reading .bash_profile and acquiring LC_COLLATE=POSIX. Let me repeat it:
The invocation chain for evolution, namely:
$ ps fax ... 1710 ? Ss 0:00 /usr/sbin/gdm-binary -nodaemon 14284 ? S 0:00 _ /usr/libexec/gdm-simple-slave --display-id /org/gnome/Disp 14285 tty7 Ss+ 0:43 _ /usr/bin/Xorg :0 -br -verbose -auth /var/run/gdm/auth- 14366 ? S 0:00 _ pam: gdm-password 14413 ? Ssl 0:00 _ gnome-session 14523 ? Sl 0:00 _ metacity 14536 ? S 0:00 _ gnome-panel 14537 ? S 0:00 _ nautilus 14542 ? S 0:00 _ /bin/sh /usr/lib64/firefox-3.5.4/run-mozilla.s 14651 ? Sl 0:41 | _ /usr/lib64/firefox-3.5.4/firefox 14543 ? Sl 0:17 _ evolution ...
doesn't show a shell of any kind anywhere between gdm, which manages the login screen, and evolution, which knows that LC_COLLATE=POSIX. Very likely the good guy is gnome-session. Maybe I should examine the gnome-session code (What's open source for, anyway?), but I have been too lazy.
Thanks to all - jon
On 11/02/09 04:28, quoth Suvayu Ali:
Hi Steven,
On Sunday 01 November 2009 09:32 PM, Steven W. Orr wrote:
On 10/31/09 03:39, quoth Jonathan Ryshpan:
IT IS WRONG to set environment variables in your .bashrc unless you really know what you're doing. Most people don't. IT IS WRONG to have to run a terminal emulator program with the idea that it should be a login shell. ALL PROGRAMS use the environment, not just terminal emulators. If you log in then your environment should be defined.
What is your comment on the method I posted, have your .bash_profile source your .bashrc ? That way you have a consistent environment every time, irrespective of whether I am at an xterm or VT or simply running some GUI app from a menu or icon. (I am of course assuming my desktop environment sources my .bash_profile, as it should, when I login :) )
Would you say that is a proper way to do things?
It is correct that the .bash_profile should source in the .bashrc but it is wrong for a terminal emulator to be executed as a login process to account for gdm's deficiency.
First of all your .bash_profile should source in your .bashrc or else you won't get any of your bashrc content in your login process. Starting a login process must run your .bash_profile and starting a sub shell process must run the .bashrc This means that the .bashrc must be run by the .bash_profile or else the login process will never get any of your local aliases, functions and variable settings.
This confuses a lot of people:
* When you log in, the login process must define the environment. This is done by sucking in the ~/.bash_profile after the /etc/profile
* The ~/.bashrc is sucked in automatically only by sub shells. To get bashrc content added to your login shell, the ~/.bash_profile must pull in the ~/.bashrc
* The /etc/bashrc is not run by the system. The user is responsible for doing this himself. In your ~/.bashrc should be a line that says: . /etc/bashrc
All of what I describe above is how things should be done, but it is *wrong* for the gdm login process to not run the correct files for you in the first place. That is why I have showed you how to go about the process of fixing it properly. You need to see about pulling in the /etc/profile and ~/.bash_profile from the /etc/X11/xinit system. You will *probably* be able to add a file (maybe call it) /etc/X11/xinit/xinitrc.d/00_bash_init.sh It should say something like what I mentioned above. I recommend *not* making it executable even though all of the files in /etc/X11/xinit/xinitrc.d are. This just confuses people more. Sourced files are not executed; they are read into a current shell.
If you do it wrong then you will be putting a crappy bandage on a system that is capable of much elegance. The whole point of environment variables is to define what *all* child processes will inherit. Look at the env command. It's not about what you see as being used by bash. It's about what the getenv(3) and setenv(3) runtime calls make available to all child processes, irrespective of what language they are written in. The environment is agnostic about linguistics.
Let's look at an example. In my environment, I define XFILESEARCHPATH and XUSERFILESEARCHPATH. If I do it then my applications will start up with the correct set of resources. If I don't then they will not. But what I will not accept is that I must start my applications from a terminal emulator that was artificially started with a --login option. That's just silly. If I want to create a button that run my application then I expect that button to be running in the proper environment that has those variables set to the values that I have defined.
Make sense?
On 11/02/09 12:20, quoth Jonathan Ryshpan:
On Sat, 2009-10-31 at 21:34 -0500, Mikkel wrote:
Jonathan Ryshpan wrote:
It looks like environment variables set in .bash_profile are visible to applications started in gnome but not via a shell. For example evolution knows when I modify LC_COLLATE.
It depends on the type of shell. Only a login shell reads .bash_profile. If you are starting a (x)terminal, and launching the program from there, the default is not to run your as a login shell.
Thanks to all for your advice on this. However I have a *question* and not a *problem*. I have LC_COLLATE=POSIX in .bash_profile and not in .bashrc, and everything is working just as I would like it to. If I find problems in the future, I may move it into .bashrc, which is invoked from .bash_profile, in exactly the way that Suvayu Ali recommended; this method is in the standard .bash_profile located in /etc/skel.
My *question* is what process is reading .bash_profile and acquiring LC_COLLATE=POSIX. Let me repeat it:
The invocation chain for evolution, namely:
$ ps fax ... 1710 ? Ss 0:00 /usr/sbin/gdm-binary -nodaemon 14284 ? S 0:00 _ /usr/libexec/gdm-simple-slave --display-id /org/gnome/Disp 14285 tty7 Ss+ 0:43 _ /usr/bin/Xorg :0 -br -verbose -auth /var/run/gdm/auth- 14366 ? S 0:00 _ pam: gdm-password 14413 ? Ssl 0:00 _ gnome-session 14523 ? Sl 0:00 _ metacity 14536 ? S 0:00 _ gnome-panel 14537 ? S 0:00 _ nautilus 14542 ? S 0:00 _ /bin/sh /usr/lib64/firefox-3.5.4/run-mozilla.s 14651 ? Sl 0:41 | _ /usr/lib64/firefox-3.5.4/firefox 14543 ? Sl 0:17 _ evolution ...
doesn't show a shell of any kind anywhere between gdm, which manages the login screen, and evolution, which knows that LC_COLLATE=POSIX. Very likely the good guy is gnome-session. Maybe I should examine the gnome-session code (What's open source for, anyway?), but I have been too lazy.
Thanks to all - jon
Great question. The answer is that if gnome-session is not a bash process then it is probably the result of a bash process that became gnome-session after running the xinit component and then doing an exec. The exec results in gnome-session and preservation of the established environment.
See my reply to Suvayu dated 12:57 EST.
On Mon, 2009-11-02 at 13:03 -0500, Steven W. Orr wrote:
On 11/02/09 12:20, quoth Jonathan Ryshpan:
My *question* is what process is reading .bash_profile and acquiring LC_COLLATE=POSIX. Let me repeat it:
The invocation chain for evolution, namely: <deleted...> doesn't show a shell of any kind anywhere between gdm, which manages the login screen, and evolution, which knows that LC_COLLATE=POSIX. Very likely the good guy is gnome-session. Maybe I should examine the gnome-session code (What's open source for, anyway?), but I have been too lazy.
Thanks to all - jon
Great question. The answer is that if gnome-session is not a bash process then it is probably the result of a bash process that became gnome-session after running the xinit component and then doing an exec. The exec results in gnome-session and preservation of the established environment.
See my reply to Suvayu dated 12:57 EST.
Your theory that gnome-session is exec-ed by bash is a reasonable one. It appears that gnome, at least, is sourcing in the environment variables (LC_COLLATE at least) as you say it should, which would make it unnecessary to source them in *again* in each individual shell. Except, of course, that the method that gnome uses to acquire them is that they be in .bash_login.
Interesting.
Thanks - jon
Hi Steven,
Steven W. Orr wrote:
On 11/02/09 04:28, quoth Suvayu Ali:
Hi Steven,
On Sunday 01 November 2009 09:32 PM, Steven W. Orr wrote:
On 10/31/09 03:39, quoth Jonathan Ryshpan:
IT IS WRONG to set environment variables in your .bashrc unless you really know what you're doing. Most people don't. IT IS WRONG to have to run a terminal emulator program with the idea that it should be a login shell. ALL PROGRAMS use the environment, not just terminal emulators. If you log in then your environment should be defined.
What is your comment on the method I posted, have your .bash_profile source your .bashrc ? That way you have a consistent environment every time, irrespective of whether I am at an xterm or VT or simply running some GUI app from a menu or icon. (I am of course assuming my desktop environment sources my .bash_profile, as it should, when I login :) )
Would you say that is a proper way to do things?
It is correct that the .bash_profile should source in the .bashrc but it is wrong for a terminal emulator to be executed as a login process to account for gdm's deficiency.
First of all your .bash_profile should source in your .bashrc or else you won't get any of your bashrc content in your login process. Starting a login process must run your .bash_profile and starting a sub shell process must run the .bashrc This means that the .bashrc must be run by the .bash_profile or else the login process will never get any of your local aliases, functions and variable settings.
This confuses a lot of people:
- When you log in, the login process must define the environment. This is done
by sucking in the ~/.bash_profile after the /etc/profile
- The ~/.bashrc is sucked in automatically only by sub shells. To get bashrc
content added to your login shell, the ~/.bash_profile must pull in the ~/.bashrc
- The /etc/bashrc is not run by the system. The user is responsible for doing
this himself. In your ~/.bashrc should be a line that says: . /etc/bashrc
All of what I describe above is how things should be done, but it is *wrong* for the gdm login process to not run the correct files for you in the first place. That is why I have showed you how to go about the process of fixing it properly. You need to see about pulling in the /etc/profile and ~/.bash_profile from the /etc/X11/xinit system. You will *probably* be able to add a file (maybe call it) /etc/X11/xinit/xinitrc.d/00_bash_init.sh It should say something like what I mentioned above. I recommend *not* making it executable even though all of the files in /etc/X11/xinit/xinitrc.d are. This just confuses people more. Sourced files are not executed; they are read into a current shell.
I know what you mean. I have to do a lot of data analysis at the university and we use a really complex framework written in C++, called ATHENA. To ensure all the various sub-packages /behave/ with each other we use environment variables controlled with lots of sourced shell scripts. Its really amazing and extremely elegant way of controlling how things behave. :)
If you do it wrong then you will be putting a crappy bandage on a system that is capable of much elegance. The whole point of environment variables is to define what *all* child processes will inherit. Look at the env command. It's not about what you see as being used by bash. It's about what the getenv(3) and setenv(3) runtime calls make available to all child processes, irrespective of what language they are written in. The environment is agnostic about linguistics.
Let's look at an example. In my environment, I define XFILESEARCHPATH and XUSERFILESEARCHPATH. If I do it then my applications will start up with the correct set of resources. If I don't then they will not. But what I will not accept is that I must start my applications from a terminal emulator that was artificially started with a --login option. That's just silly. If I want to create a button that run my application then I expect that button to be running in the proper environment that has those variables set to the values that I have defined.
Make sense?
Thank you for this entire reply Steven. All the subtleties you mentioned makes a lot of sense. Following these simple rules makes everything work consistently whether its being run from an xterm, VT or from a button on my desktop. I'll try to go over what you said again and try to keep those in mind while investigating any future issues and will definitely try to include any such information in any bug report I contribute to. Thanks a lot, learned a lot. :)
hi.
I just want to report one issue which I just observed.
In FC11 file browser, when I click Edit-> Preference the window disappears.
I am wondering whether its some config issue or some bug ?
I am using core 2 due, 4GB, ASUS notebook.
Jonathan Ryshpan <jonrysh <at> pacbell.net> writes:
It looks like environment variables set in .bash_profile are visible to applications started in gnome but not via a shell. For example evolution knows when I modify LC_COLLATE.
But how? Here's the invocation chain from login down to evolution -- no shells here.
1710 ? Ss 0:00 /usr/sbin/gdm-binary -nodaemon 14284 ? S 0:00 _ /usr/libexec/gdm-simple-slave --display-id
/org/gnome/Disp
14285 tty7 Ss+ 0:43 _ /usr/bin/Xorg :0 -br -verbose -auth
/var/run/gdm/auth-
14366 ? S 0:00 _ pam: gdm-password 14413 ? Ssl 0:00 _ gnome-session 14523 ? Sl 0:00 _ metacity 14536 ? S 0:00 _ gnome-panel 14537 ? S 0:00 _ nautilus 14542 ? S 0:00 _ /bin/sh
/usr/lib64/firefox-3.5.4/run-mozilla.s
14651 ? Sl 0:41 | _ /usr/lib64/firefox-3.5.4/firefox 14543 ? Sl 0:17 _ evolution
What am I missing?
Thanks - jon
See this excellent post by Chris Tyler where he explores the sequence of events leading to execution of .bash_profile:
http://dailypackage.fedorabook.com/index.php?/archives/122-Wednesday-Why-Log...
The critical line is in the /etc/X11/xdm/Xsession script:
exec -l $SHELL -c "$SSH_AGENT $DBUS_LAUNCH gnome-session"
where SHELL is bash.
Allen
On Thu, 2009-11-05 at 02:02 +0000, Allen Halsey wrote:
Jonathan Ryshpan <jonrysh <at> pacbell.net> writes:
It looks like environment variables set in .bash_profile are visible to applications started in gnome but not via a shell. For example evolution knows when I modify LC_COLLATE.
But how? Here's the invocation chain from login down to evolution -- no shells here...
See this excellent post by Chris Tyler where he explores the sequence of events leading to execution of .bash_profile:
http://dailypackage.fedorabook.com/index.php?/archives/122-Wednesday-Why-Log...
The critical line is in the /etc/X11/xdm/Xsession script:
exec -l $SHELL -c "$SSH_AGENT $DBUS_LAUNCH gnome-session"
where SHELL is bash.
Thanks. The article seems to be about the exact question I asked. (Haven't had a chance to read it yet.)
jon