Bug 315853 - Kate Build plugin fails to use environment variables and PATH
Summary: Kate Build plugin fails to use environment variables and PATH
Status: RESOLVED NOT A BUG
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 4.0
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-27 15:34 UTC by infinity.probability@gmail.com
Modified: 2013-02-28 20:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description infinity.probability@gmail.com 2013-02-27 15:34:13 UTC
Kate Build plugin fails to use environment variables and PATH. If a script setting a variable or sourcing some script is put in .kde/env, Kate Build plugin cannot see the variables or programs set. 

Example: sourcing the following file 

#!/bin/sh
source /opt/intel/mkl/bin/mklvars.sh intel64
source /opt/intel/composer_xe_2013/bin/compilervars.sh intel64

should enable the intel compiler to be found by make and used. Kate started from the menu can't see the compiler, but if Kate is started from the terminal it can see the the compiler correctly.

Reproducible: Always

Steps to Reproduce:
1. Put a script in ~/.kde/env to be sourced when the session starts.
2. Open Kate, configure the Build plugin to use make.
3. Use "Build" from Kate menu.
Actual Results:  
 make complains it can't find the executable set in the script.

Expected Results:  
Call the executable (compiler) correctly.
Comment 1 Kåre Särs 2013-02-27 19:32:47 UTC
I'm a bit confused... how is this a problem in the build plugin?

Clearly Kate is started with different environment variables set (Terminal/Menu).

It seems you always want those scripts to be sourced. Why don't you put them in ~/.bachrc?

I personally would not source those files on session startup. I would just add a "source some/file.sh" before the "make" command. Something like:

"source ~/.kde/env/somefile.sh make"

That way you can have many different build environments without being afraid of conflicts.

I'll mark this as invalid as I don't think there is anything kate (or the plugin) should do about it. I can understand that you would like the have the same environment when started from Terminal/Menu, but that is more a thing for the shell.

Hope this helps,
  Kåre
Comment 2 infinity.probability@gmail.com 2013-02-27 20:31:12 UTC
Hi Kare (sorry about the a, I can't type it here on my present keyboard)

I already have the configuration correctly sourced in my .bashrc and Kate fails the same way to find the environment variables. Note that this case is particular to source something (the Intel compiler), but what if I want to Kate (or any other KDE program) to get something sourced in .kde/env or even .bashrc? 

The same way, I agree that "is more a thing for the shell", but if that was the only case I would be using vi and not Kate, and that obviously is not my objective. 

BTW, your suggestion of sourcing in the makefile is nice (I liked the idea!), but not what I'm talking about this bug report. If you tell me that the Build plugin or Kate _must_ not get the variables that I set and should only get the variables from /etc/profile I'll accept this bug closed and will open another, more pertinent one. Otherwise, I'm keeping it as unconfirmed.

Thank you for your time,
Comment 3 Dominik Haumann 2013-02-27 23:23:03 UTC
Kåre is right here: this certainly is not a bug of Kate, as Kate just uses the environment variables that are available in the usual KDE session. It does not intentionally unset or ignore environment variables.

That said, we are not going to parse files for environment variables ourselves. If it really doesn't work, please report bugs to kdelibs with the appropriate component (the one that reads .kde/env. btw, are you sure it shouldn't be .kde4/env ? Is the file executable?).

I'll close this report again, sorry.
Comment 4 Dominik Haumann 2013-02-27 23:24:48 UTC
Another way would be to ask on kde-devel@kde.org for this particular issue. I'm pretty sure you'd get a qualified answer there, as there are developers who really know how this is supposed to work.
Comment 5 infinity.probability@gmail.com 2013-02-28 16:19:53 UTC
That's my point: it seems that Kate is not using the variables set in .kde/env (it's not .kde4 in my system, is .kde, and the file is executable). So maybe this is a misunderstanding from my side: as it really doesn't work (Kate can't find a new PATH set in a executable script in .kde/env, for example), what is the proper way to set environment variables for KDE? 

The source to files in .kde/env is done by the script startkde, and scripts in .kde/env are sourced correctly - I checked. Can this bugreport be redirected to the proper component? Sending an email for this instead of a bug report feels out of place. 

I'll also ask in kde-devel list anyway. The documentation for environment variables for KDE is here: http://userbase.kde.org/Session_Environment_Variables

Thanks again,
Comment 6 Kåre Särs 2013-02-28 18:51:49 UTC
Hi,

I have now tested it out and I think the problem is that your .kde/env/ script does not like dash...

Removing "#!/bin/sh" and replacing "source" with "." should make it work.

/Kåre
Comment 7 infinity.probability@gmail.com 2013-02-28 20:12:06 UTC
Hey Kåre,

I tried removing sh and still didn't work. Interesting enough, if I don't
source the intel script it doesn't work, I can't just execute it. It is
getting
more clear what's going on. I'll try to dig a bit further and I'll let you
know.

Cheers


2013/2/28 Kåre Särs <kare.sars@iki.fi>

> https://bugs.kde.org/show_bug.cgi?id=315853
>
> --- Comment #6 from Kåre Särs <kare.sars@iki.fi> ---
> Hi,
>
> I have now tested it out and I think the problem is that your .kde/env/
> script
> does not like dash...
>
> Removing "#!/bin/sh" and replacing "source" with "." should make it work.
>
> /Kåre
>
> --
> You are receiving this mail because:
> You reported the bug.
>
Comment 8 Kåre Särs 2013-02-28 20:45:20 UTC
I tried this:

did not work:
#!/bin/sh
source /home/sars/tast_path.sh

Did work:
. /home/sars/test_path.sh

Note the '.' notation for "source". I'm not sure what is wrong and why . worked for me. I have a hunch that it might be dash that plays a trick...

/Kåre