How do I make sure ~/.bash_profile is run?

This forum is dedicated to basic help and support :

Ask here your questions about basic installation and usage of Mageia. For example you may post here all your questions about getting Mageia isos and installing it, configuring your printer, using your word processor etc.

Try to ask your questions in the right sub-forum with as much details as you can gather. the more precise the question will be, the more likely you are to get a useful answer

How do I make sure ~/.bash_profile is run?

Postby jaywalker » Sep 17th, '12, 17:02

This feels like a Basic Support issue. I cannot imagine that the answer is not forehead-slappingly obvious but I am having one of those days :(

The gory details:
Distribution: fully updated MGA2 on x86_64
Desktop is LXDE started from LXDM
Problem is my .bash_profile contains the standard
Code: Select all
PATH=$PATH:$HOME/bin
, but my PATH doesn't:
Code: Select all
[richard@Tureen ~]$ echo $PATH
/usr/lib64/libfm:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/games:/usr/lib64/qt4/bin


Can some kind soul please tell me where I should start looking for the solution?

Richard
jaywalker
 
Posts: 341
Joined: Nov 17th, '11, 02:38
Location: Belfast, Northern Ireland

Re: How do I make sure ~/.bash_profile is run?

Postby alf » Sep 17th, '12, 17:33

jaywalker wrote:PATH=$PATH:$HOME/bin


and PATH is exported in your .bash_profile?
Code: Select all
# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
for windows problems reboot; for linux problems be root
alf
 
Posts: 326
Joined: Apr 1st, '11, 23:07
Location: DE Paderborn

Re: How do I make sure ~/.bash_profile is run?

Postby jaywalker » Sep 17th, '12, 18:57

Sorry, I was being too economical perhaps. The .bash_profile is completely standard, as originally installed, and the same as on three other systems and is as follows
Code: Select all
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
   . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
GB_GUI=gb.qt4

export PATH
export GB_GUI
unset USERNAME

OK, standard + the GB_GUI stuff which I added today as part of the same task to be able to easily start Gambas programs (in ~/bin) from the command line. Of course, the GB_GUI variable is not set either. I think this means that the ~/.bash_profile is not being run.

R
jaywalker
 
Posts: 341
Joined: Nov 17th, '11, 02:38
Location: Belfast, Northern Ireland

Re: How do I make sure ~/.bash_profile is run?

Postby djennings » Sep 19th, '12, 21:18

Maybe a silly question, but is ~/.bash_profile executable, and is it owned by your user?

If you have installed Mageia over an existing installation it is possible files in your home are owned by the wrong UID.
User avatar
djennings
 
Posts: 613
Joined: Jun 2nd, '11, 23:51
Location: Wokingham, UK

Re: How do I make sure ~/.bash_profile is run?

Postby jaywalker » Sep 19th, '12, 23:41

djennings wrote:Maybe a silly question, but is ~/.bash_profile executable


I have just checked two of my Mageia 2 installations, incidentally, both started life as Cauldron Beta2 (or was it 3) back in the day, and none of them has the execute bit set on .bash_profile. Nevertheless, the one I am using now does indeed have the $HOME/bin definition added to the PATH variable.

But that started me thinking. I read somewhere, probably in the bash man page, that you don't need the execute bit to be set if the contents of the file is "absorbed" somehow by some other script which is executing. I don't recall the technical term but I remember wondering at the time if might be something akin to an included file. Anyway, that must be what is going on here because none of the .bash_profile files is executable - not even the one on a Mandriva 2010 box.

I was hoping that someone might know how the ~/.bash_profile is run - surely something needs to "call" it or "include" it?

PS. And yes, I own them all (cackle, fiendish cackle, megalomaniacal guffaw)


Richard
jaywalker
 
Posts: 341
Joined: Nov 17th, '11, 02:38
Location: Belfast, Northern Ireland

Re: How do I make sure ~/.bash_profile is run?

Postby martinw » Sep 19th, '12, 23:50

~.bash_profile is only executed by a login shell. How are you starting bash? If it's being started by lxterminal, I think there's an option in lxterminal to cause the initial shell to be a login shell.
martinw
 
Posts: 608
Joined: May 14th, '11, 10:59

Re: How do I make sure ~/.bash_profile is run?

Postby jaywalker » Sep 20th, '12, 00:56

martinw wrote:~.bash_profile is only executed by a login shell. How are you starting bash? If it's being started by lxterminal, I think there's an option in lxterminal to cause the initial shell to be a login shell.


OK, I think I am getting somewhere. There is a file in /etc/lxdm (which is the display manager I use) called Xsession which has a line:
Code: Select all
[ -f ~/.profile ] && . ~/.profile


On this system (where ~/bin is correctly set in the PATH) ~/.profile is linked to ~/.bash_profile so that seems to explain that. This system also has an Xsession file in 4 locations, so I suppose one of them must be "the real thing". My money is on /etc/X11/Xsession
Code: Select all
[richard@Bathtub ~]$ locate Xsession
/etc/X11/Xsession
/etc/X11/xdm/Xsession
/etc/lxdm/Xsession
/usr/share/X11/xdm/Xsession


OK, I have had a poke through /etc/X11/Xsession. Man that looks complicated. My best guess at the moment is that something in all that complexity finds a good way to start LXDE (via the /etc/lxdm/Xsession file perhaps) but on the other system it loses track of where it is going but somehow still manages to start LXDE without going through /etc/lxdm/Xsession - hence no .profile leading to running .bash_profile.

I'll have another look when I'm not so tired. Thanks to all above.

Richard
jaywalker
 
Posts: 341
Joined: Nov 17th, '11, 02:38
Location: Belfast, Northern Ireland


Return to Basic support

Who is online

Users browsing this forum: No registered users and 1 guest

cron