Bug 167502 - .desktop file not honoring PATH environment variable
Summary: .desktop file not honoring PATH environment variable
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kservice
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-27 01:40 UTC by Juan Ignacio Saitua
Modified: 2021-08-25 22:13 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot (51.40 KB, image/png)
2020-07-26 08:07 UTC, Holger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Juan Ignacio Saitua 2008-07-27 01:40:43 UTC
Version:            (using KDE 3.5.9)
Installed from:    Ubuntu Packages
OS:                Linux

This is the situation:
 - I have myapp in /usr/bin/myapp and in /opt/bin/myapp
 - I also have myapp_entry.desktop in /usr/share/applications with the Exec line as "Exec=myapp"
 - I added /opt/bin into PATH (editing /etc/environment). So PATH has the following: /opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Now, when I launch "kdialog --msgbox `echo $PATH`" using ALT+F2 it shows correctly: /opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

When I launch "myapp" using ALT+F2 it runs /opt/bin/myapp as expected.
But, and this is what I think is a BUG, when I launch "myapp_entry" using ALT+F2 it runs /usr/bin/myapp and not /opt/bin/myapp as I would expect.
Comment 1 Juan Ignacio Saitua 2008-07-31 22:47:41 UTC
Found where the problem is. It's in the KStandardDirs::findExe() function. From line 937 (http://api.kde.org/3.5-api/kdelibs-apidocs/kdecore/html/kstandarddirs_8cpp-source.html#l00937)

QString p = QString("%1/%2").arg(kfsstnd_defaultbindir()).arg(real_appname);

you can see that it uses function kfsstnd_defaultbindir() to get the absolute path to the application. KStandardDirs::kfsstnd_defaultbindir() returns __KDE_BINDIR and, from the ubuntu packages, the default compiled value for __KDE_BINDIR is /usr/bin. So, it doesn't matter what you set in your PATH environment variable, but it always will execute /usr/bin/myapp.

IMHO, I think that KStandardDirs::findExe() should use KStandardDirs::kfsstnd_defaultbindir() as the last option to find the absolute path to the application (and not as the second one, as is coded right now).

Any comments? Thanks...
Comment 2 Andrew Crouthamel 2018-11-02 04:28:39 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Andrew Crouthamel 2018-11-16 02:48:53 UTC
Dear Bug Submitter,

This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version?

Thank you for helping us make KDE software even better for everyone!
Comment 4 Holger 2020-07-26 08:07:03 UTC
Created attachment 130404 [details]
Screenshot

Trying to use an environment variable in the working directory (even though it is suggested by the edit dialog) will break the search for the executable and not run the program. In addition usage of "~" also fails to resolve $HOME.
Comment 5 Alexander Lohnau 2020-08-02 17:52:19 UTC
(In reply to Holger from comment #4)
> Created attachment 130404 [details]
> Screenshot
> 
> Trying to use an environment variable in the working directory (even though
> it is suggested by the edit dialog) will break the search for the executable
> and not run the program. In addition usage of "~" also fails to resolve
> $HOME.

Can you please file two separate bugs for this. Thanks!
Comment 6 Holger 2020-08-03 20:27:15 UTC
done: bug 424973 & bug 424974
Comment 7 David Faure 2020-08-14 10:17:49 UTC
Is the original bug still present?

KStandardDirs is no longer used, there's no __KDE_BINDIR anymore, etc.
Comment 8 Ahmad Samir 2021-08-25 22:13:23 UTC
I tested, looks fixed to me.