You are not logged in.

#1 2010-08-18 18:19:53

archtaku
Member
Registered: 2010-07-02
Posts: 84

scripts in /etc/profile.d seem not to work under certain circumstances

While already logged in, if I open up a terminal and run a script in /etc/profile.d/ to set environment variables, the changes don't seem to take. I can think of two examples:

1) Turning on KDE4 desktop integration in openoffice. I edited /etc/profile.d/openoffice.sh and changed OOO_FORCE_DESKTOP=KDE4, but when I ran the script I got an "export: command not found" error.

2) When replacing Sun Java with OpenJDK in order to compile and use 389-console from the AUR, I got caught up on one of the dependencies, ldapjdk (also from the AUR). The PKGBUILD for this package contains the following block of code:

which ant
if [ $? -eq 1 ]; then
  . /etc/profile.d/apache-ant.sh
fi
ant dist

In theory this should work, as /etc/profile.d/apache-ant.sh contains the following two lines:

export ANT_HOME=/usr/share/java/apache-ant
export PATH=$PATH:$ANT_HOME/bin

However, upon running makepkg I got an error about "ant" not being in my path. To get around this I just edited the PKGBUILD and put the full path to ant, but this shouldn't have been necessary. The original PKGBUILD should have worked. I seem to have something out of whack and I don't quite know what. If anyone could be of assistance, it would be much appreciated.

Offline

#2 2010-08-20 22:22:44

xvello
Member
Registered: 2010-05-15
Posts: 81
Website

Re: scripts in /etc/profile.d seem not to work under certain circumstances

Hello

Setting up environment variables only work on the shell session you did it (and every process spawned from this session), which means setting a variable on a konsole window will never impact openoffice launched via the plasma menu.

For changes / additions in profile.d to be effective in your graphical session, you have to restart xorg.


Hope it helps

Offline

#3 2010-08-20 22:36:27

archtaku
Member
Registered: 2010-07-02
Posts: 84

Re: scripts in /etc/profile.d seem not to work under certain circumstances

I'm well aware of this. I never said that I started openoffice from the plasma menu. I never even started it. /etc/profile.d/openoffice.sh errored out without setting the environment variable in the current shell session. If it had worked, I would have been able to run openoffice from the terminal to test the new environment variable, which is what I was intending to do in the first place. There's no need to logout to test these sort of changes, they can be done from the terminal.

Your solution also doesn't address the problem I had in example #2, either. makepkg should be able to set environment variables in the current shell session, using the /etc/profile.d script detailed in the example. Running makepkg has nothing to do with my graphical session.


I know that logging out and back in will "fix" the problem, but that's not the point. The point is that a script which should be able to set an environment variable is not working properly.

Last edited by archtaku (2010-08-21 00:58:53)

Offline

#4 2010-08-20 23:05:18

archtaku
Member
Registered: 2010-07-02
Posts: 84

Re: scripts in /etc/profile.d seem not to work under certain circumstances

I found the issue with example #1. I wasn't sourcing /etc/profile.d/openoffice.sh, I was just running it. (i.e. /etc/profile.d/openoffice.sh instead of . /etc/profile.d/openoffice.sh). So, a big "d'oh!" on that one.

However, the PKGBUILD in example #2 was sourcing the script, so it's weird that it didn't work.

Last edited by archtaku (2010-08-20 23:05:34)

Offline

Board footer

Powered by FluxBB