Bug 448859 - KEmailClientLaucherJob can't lauch Thunderbird with env variable in Exec
Summary: KEmailClientLaucherJob can't lauch Thunderbird with env variable in Exec
Status: RESOLVED NOT A BUG
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Ahmad Samir
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-21 00:45 UTC by Nicolas Fella
Modified: 2022-08-19 06:23 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.92


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Fella 2022-01-21 00:45:28 UTC
STEPS TO REPRODUCE
1. Change the Exec line in the Thunderbird desktop file to "MOZ_ENABLE_WAYLAND=1 /usr/lib/thunderbird/thunderbird %u" 
2. Set thunderbird as default email client
3. Create and start a KEmailClientLauncherJob

OBSERVED RESULT
Thunderbird does not open

kf.kio.gui: Failed to register new cgroup: "app--a2814818d4114405bc37e453a8dc3eaf.scope" "org.freedesktop.DBus.Error.UnixProcessIdUnknown" "Process with ID 125248 does not exist."

This is because KIO::DesktopExecParser::executableName trips over the env variable

Removing the env variable makes it work

EXPECTED RESULT
Thunderbird opens

SOFTWARE/OS VERSIONS
KDE Plasma Version: master
KDE Frameworks Version: master
Qt Version: 5.15-kde
Comment 1 Bug Janitor Service 2022-02-09 16:31:08 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/751
Comment 2 Ahmad Samir 2022-02-23 16:12:22 UTC
Git commit 4c4f4b919a81706913596e7ba518165dd80c9eb7 by Ahmad Samir.
Committed on 23/02/2022 at 11:44.
Pushed by ahmadsamir into branch 'master'.

DesktopExecParser: parse environment variables too

And add a method that returns a QProcessEnvironment object containing those
environment variables (thanks to Meven for the idea of returning a QPE).

Add unittest.
FIXED_IN: 5.92

M  +33   -0    autotests/krununittest.cpp
M  +2    -0    autotests/krununittest.h
M  +36   -1    src/core/desktopexecparser.cpp
M  +28   -3    src/core/desktopexecparser.h

https://invent.kde.org/frameworks/kio/commit/4c4f4b919a81706913596e7ba518165dd80c9eb7
Comment 3 Fabian Vogt 2022-02-25 13:43:49 UTC
I don't think specifying environment variables like this is valid. The Exec= line must start with the application and must not contain '=':

https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s07.html

A command line consists of an executable program optionally followed by one or more arguments. The executable program can either be specified with its full path or with the name of the executable only. If no full path is provided the executable is looked up in the $PATH environment variable used by the desktop environment. The name or path of the executable program may not contain the equal sign ("="). Arguments are separated by a space.

So the previous KIO behaviour was probably correct and the change should be reverted.
Comment 4 Nicolas Fella 2022-02-25 13:51:03 UTC
The thing is, launching the app works perfectly fine and sets the env variable, it's just that executableName behaves differently
Comment 5 Fabian Vogt 2022-02-25 13:57:24 UTC
(In reply to Nicolas Fella from comment #4)
> The thing is, launching the app works perfectly fine and sets the env
> variable, it's just that executableName behaves differently

I'd say that's a bug - KIO should not accept it at all as it's invalid. That can cause weird issues and hide compatibility problems.

I wonder how it works at all, it probably ends up in a /bin/sh context at some point.
Comment 6 David Faure 2022-03-04 22:59:19 UTC
Yes this ends up in /bin/sh. I thought any shell command was valid for an Exec line.
Thanks for the pointer to the spec, that's instructive. Sometimes we voluntarily support more things than the spec, but it's probably not a great idea (creates compat problems when people test something in KDE and assume it'll work everywhere)

I just found desktop files that say

Exec=env WINEPREFIX="/home/dfaure/.wine" wine start /ProgIDOpen giffile %f

Isn't this a solution to this problem? I.e. change step 1 to prepend "env" before the env var?
Comment 7 Ahmad Samir 2022-04-18 22:35:44 UTC
FTR, the commit was reverted.

The solution David posted works?
Comment 8 Ahmad Samir 2022-07-11 20:21:38 UTC
Ping.
Comment 9 Nicolas Fella 2022-07-20 09:37:01 UTC
yes, env FOO=bar works
Comment 10 Bug Janitor Service 2022-08-04 04:35:27 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 11 Bug Janitor Service 2022-08-19 04:35:36 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!