Bug 242834 - .desktop shortcuts don't respect $PATH
Summary: .desktop shortcuts don't respect $PATH
Status: RESOLVED DUPLICATE of bug 241763
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: kdecore (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-26 02:56 UTC by Jeremy
Modified: 2012-01-05 18:25 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Example of .desktop file which experiences this issue (660 bytes, application/octet-stream)
2010-06-26 02:56 UTC, Jeremy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy 2010-06-26 02:56:41 UTC
Created attachment 48339 [details]
Example of .desktop file which experiences this issue

Version:           unspecified (using KDE 4.4.2) 
OS:                Linux

I have added $HOME/bin to the beginning of $PATH, but .desktop files seem to ignore versions of executables in $HOME/bin if a "system installed" (/usr/bin,/usr/sbin,etc...) exists even though $HOME/bin comes first in $PATH. 

I have tried adding "export PATH=$HOME/bin:$PATH" to ~/.profile, ~/.bashrc, ~/.kde/env/path.sh, and /etc/environment. ALL of them update the PATH and allow for executing the correct $HOME/bin executables when executing from a terminal session. However NONE of them execute the correct version from any .desktop files, the KDE Run Command window or xdg-open. All desktop shortcuts are saved without an absolute path ("firefox" instead of "/usr/bin/firefox").

I have deleted ~/.kde and ~/.kde4 and also created a brand new user using adduser command from terminal and still have the issue. I have added "echo $PATH" to ~/.kde/Autostart/echo and checking ~/.xsession-errors showed a PATH identical to what is output from the terminal (in the correct order).

Reproducible: Always

Steps to Reproduce:
Update path with "export PATH=$HOME/bin:$PATH"
Install an executable in $HOME/bin with the same name as a system installed version (/usr/bin)
create a .desktop shortcut or execute from Run Command dialog the executable without an absolute path

Actual Results:  
executes the "system installed" executable

Expected Results:  
should execute $HOME/bin version of executable

I am currently using Kubuntu 10.04 and for a short time openSuSE 11.2 both with KDE 4.4.2. I did not experience this issue Kubuntu 9.10.
Comment 1 Gabriel Corona 2011-02-07 14:05:23 UTC
I think it is a duplicate of bug 241763. It should be fixed in trunk now.
Comment 2 Mark 2012-01-05 16:44:02 UTC
Oh wow, i hate this bug!
I've really spend days (and counting) to find out what is going wrong since i'm having the exact same issue as the Jeremy and i went through a lot of config files and frustration to let the darn $PATH variable be USED... the way i set it.

So after digging in this i first encountered xdg-open (like Jeremy mentions). However, xdg-open is just a bash script that in turn calls kde-open! So, unsurprisingly the result between xdg-open and kde-open is exactly the same.

So, the start point for this to dig deeper is probably: http://quickgit.kde.org/?p=kde-runtime.git&a=blob&h=c4b76100481a915e0fc88d1ed14270405faa55c4&hb=3e605eeb323b17588f9086c9c5e6634328cab3f9&f=kioclient/kioclient.cpp line 172 (kde_run function).

However, that doesn't seem to do a lot and moves on to KRun which is hidden in a completely different repository (kdelibs): http://quickgit.kde.org/?p=kdelibs.git&a=blob&h=1ff6979d7182e791a97ffdcd92937b46e4838d70&hb=eb18cd88661165961d46af697840a62556fc55f4&f=kio/kio/krun.cpp

So now i'm "guessing" that KRun is the one to blame and is so for certainly 4 KDE major releases since 4.8 is just around the corner and the issue was known in 4.4 already. Just the cause isn't, yet!

I did try gdb on kde-run and i come as far as kioclient.cpp:271 after i lose it and it crashes. That line is: return app.kde_open(args->url(0), QByteArray(), false);

Where i'm guessing it ends up in the else statement thus is gonna call KRun::run(...) and there is probably the part that isn't honoring the $PATH part. ... Just guessing a bit though. I hope this gets someone started to fix this darn issue.
Comment 3 Mark 2012-01-05 18:25:48 UTC
Dupe of 241763. Ignore my last comment since it doesn't seem to be the issue.

*** This bug has been marked as a duplicate of bug 241763 ***