You are not logged in.
Hi,
Hoping someone can help.
I am trying to add a path to $XDG_DATA_HOME on login.
After googling and following examples, I have tried the following without success:
export XDG_DATA_HOME=$XDG_DATA_HOME:/path/to/add
I have tried adding the above to ~/.bash_profile, does not work.
I have also tried placing a script (and making it executable) in /etc/profile.d with the same code, does not work.
I have even created a local script and added to my startup applications, does not work.
(I have confirmed the local script is definitely run without error.)
Yet by simply entering the code into a terminal, it works.
Help!
Cheers.
[CORRECTION] Just a correction for those looking to do the same, the ~/.profile solution below works a treat. I just need to point out that you should use XDG_DATA_DIRS instead of XDG_DATA_HOME. Looking at the Freedesktop spec for base directories, XDG_DATA_HOME is treated as a single directory, thus any additions you make to it will change your settings directory causing many problems. The same goes for XDG_CONFIG_HOME, use XDG_CONFIG_DIRS instead![/CORRECTION]
Last edited by Padfoot (2011-09-12 07:52:51)
Offline
I have also tried placing a script (and making it executable) in /etc/profile.d with the same code, does not work.
I have even created a local script and added to my startup applications, does not work.
When the scripts terminate, the new variables go out of scope and are destroyed.
I have tried adding the above to ~/.bash_profile, does not work.
I think that should work. What if you put it in ~/.bashrc instead. Also, check the permissions and ownership of ~/bash_profile. Ensure you own it and it is executable.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Thanks for the heads up on the scripts.
~/.bash_profile has me annoyed though. It's as if it is not being executed. Will have to try adding something with a visible effect to confirm.
My ~/.bash_profile is owned by me and is executable but it simply will not add the path to the variable.
Could it be something to do with the way my session is handled?
I am currently launching my session through GDM via inittab. I know when a session is launched this way, for example, ~/.xinitrc is ignored. Perhaps this is the same for ~/.bash_profile?
Regarding ~/.bashrc, it does work this way, but it only adds the path when a terminal is launched. I need the path added regardless of a terminal being opened or not.
Cheers.
Offline
Confirmed, ~/.bash_profile is not being executed at all.
Offline
Confirmed, ~/.bash_profile is not being executed at all.
Sounds like starting gdm from inittab hasn't set the environment up for you right.
what does
echo $SHELL
and
echo $PATH
return?
You're just jealous because the voices only talk to me.
Offline
Did you try "~/.profile"?
Btw, "~/.bash_profile" doesn't need to be executable.
Offline
~/.bash_profile is only read when bash is started as a login shell. There's an enormous section in bash(1) called INVOCATION that describes startup behavior, including what files are read, and when.
Last edited by falconindy (2011-09-11 14:20:09)
Offline
@moetunes
$ echo $SHELL
/bin/bash
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/jre/bin:/usr/bin/vendor_perl:/usr/bin/core_perl
Looks like my environment is set up correctly.
@falconindy
Thanks for pointing that out. I was not aware bash had to be started as a login shell in this case. Normally I take great care with RTFM, but usually have a total memory lapse when it comes to man
@lunar
~/.profile is the solution. Thank you.
Problem solved. Thank you everyone for all your help.
Cheers.
Offline