Bug 430157 - KDE .desktop parser complains about files that have Type= "Application" but no Exec line, although this situation is normal.
Summary: KDE .desktop parser complains about files that have Type= "Application" but n...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kservice
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.112.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-08 15:08 UTC by lockywolf
Modified: 2023-11-19 20:55 UTC (History)
16 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.113
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lockywolf 2020-12-08 15:08:10 UTC
SUMMARY

Certain .desktop files describe applications that have no executable. An example is qemu, which has a qemu-ARCH binaries, but no binary that can be run from a GUI application. If you run any application that initialises KDE, such as khelpcenter, in the console window you will see an error report:

kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but no Exec line
kf.service.sycoca: Invalid Service :  "/usr/share/applications/qemu.desktop"

This is a misleading report (according to qemu developers).

STEPS TO REPRODUCE
1. Run a DE that is not involving KDE, such as twm.
2. run khelpcenter in a terminal
3. observer the aforementioned error message

OBSERVED RESULT

Error message

EXPECTED RESULT

No error message

SOFTWARE/OS VERSIONS
Windows: not tested
macOS: not tested
Linux/KDE Plasma:  5.4.80, 5.76.0
(available in About System)
KDE Plasma Version: 5.20.4
KDE Frameworks Version: 5.76.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION

A bug  has been reported at the qemu bug tracker, asking the developers to correct their .desktop file, but they seem to be absolutely sure that this is not a .desktop format error, but rather a kde .desktop parser bug.

https://bugs.launchpad.net/qemu/+bug/1868221?comments=all
Comment 1 flinux 2020-12-16 14:13:30 UTC
Came across this issue as well and saw you made a report :) yea it's frankly annoying now starting KDE or any other thing which works with kf.service via the terminal, you always have this error
Comment 2 Ahmad Samir 2021-08-25 19:32:16 UTC
I personally think the fix is to not ship that file at all.
Comment 3 Stefan Brüns 2021-12-09 14:50:55 UTC
(In reply to Ahmad Samir from comment #2)
> I personally think the fix is to not ship that file at all.

https://gitlab.com/qemu-project/qemu/-/issues/440#note_606080304

> We only created the qemu.desktop file in the first place because Wayland needs this to be present in order to identify what Icon to display for a window.
Comment 4 Ahmad Samir 2021-12-09 15:06:57 UTC
I had read that comment; my previous message was sort of my reply to that, creating a .desktop file that violates the desktop entry spec is wrong, and then when tools that comply with the spec print errors about that, the .desktop file should be fixed or removed.
Comment 5 Matt M (gardotd426) 2022-01-03 07:35:39 UTC
(In reply to Ahmad Samir from comment #4)
> I had read that comment; my previous message was sort of my reply to that,
> creating a .desktop file that violates the desktop entry spec is wrong, and
> then when tools that comply with the spec print errors about that, the
> .desktop file should be fixed or removed.

The problem is that it (the .desktop file) inherently *can't* be fixed, but the .desktop file is required for Wayland in order to be able to actually show the right icon when a window is open. 

So basically it can't be fixed, and it can't be removed. The only/best solution I can  think of, because this is an extraordinarily edge case, is to add an exception to kservice that specifically ignores (or at least doesn't print any errors related to) the qemu.desktop file.
Comment 6 david.scott.brown 2023-02-12 21:12:23 UTC
I am not sure this is an edge case, I believe this behavior is affecting every qemu user . For example here are my logs:

$ date
Sun Feb 12 01:05:37 PM PST 2023

$ journalctl --since "2022-02-01"  --until now |grep qemu.desktop|wc
 340896 4772544 46038142

So, 340,896 entries in 12 days. I believe this is happening to every KDE user that QEMU installed making the logs just that much more cluttered and bloated. 

OS: Fedora Linux 37 (KDE Plasma) x86_64 
Kernel: 6.1.7-200.fc37.x86_64 
DE: Plasma 5.26.5 
WM: kwin 
Theme: [Plasma], Adwaita [GTK2] 
Icons: [Plasma], breeze-dark [GTK2/3]
Comment 7 Bug Janitor Service 2023-09-09 20:42:29 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kservice/-/merge_requests/158
Comment 8 David Faure 2023-09-14 10:31:33 UTC
Git commit 25917d20effad77ac6976a672430a3aac19575d2 by David Faure.
Committed on 14/09/2023 at 12:28.
Pushed by dfaure into branch 'kf5'.

KService: allow .desktop files without an Exec line

qemu ships one of those, just to associate icons with windows on
wayland, even though there's nothing to execute (the desktop file
has NoDisplay set).

We don't need to warn here, surely we'll get an error when launching
such a desktop file (if it doesn't have NoDisplay), at runtime, right?

M  +0    -9    src/services/kservice.cpp

https://invent.kde.org/frameworks/kservice/-/commit/25917d20effad77ac6976a672430a3aac19575d2
Comment 9 David Faure 2023-09-14 10:35:20 UTC
Git commit 5203bed8bfb5c46ea3f2539d909fafc24a692ce3 by David Faure.
Committed on 14/09/2023 at 12:35.
Pushed by dfaure into branch 'master'.

KService: allow .desktop files without an Exec line

qemu ships one of those, just to associate icons with windows on
wayland, even though there's nothing to execute (the desktop file
has NoDisplay set).

We don't need to warn here, surely we'll get an error when launching
such a desktop file (if it doesn't have NoDisplay), at runtime, right?
(cherry picked from commit 25917d20effad77ac6976a672430a3aac19575d2)

M  +0    -9    src/services/kservice.cpp

https://invent.kde.org/frameworks/kservice/-/commit/5203bed8bfb5c46ea3f2539d909fafc24a692ce3
Comment 10 Yaroslav Sidlovsky 2023-10-31 09:54:30 UTC
It still spams as hell after fix from this line: https://invent.kde.org/frameworks/kservice/-/blob/25917d20effad77ac6976a672430a3aac19575d2/src/services/kservice.cpp#L939

Also not only qemu.desktop affected, both /usr/share/applications/bookmarks.desktop and /usr/share/applications/org.freedesktop.Xwayland.desktop gives such message too.

(/usr/share/applications/bookmarks.desktop goes with konqueror).
Comment 11 Yaroslav Sidlovsky 2023-10-31 10:02:45 UTC
Example output from journalctl:
```
Oct 31 12:36:38 rapidus kactivitymanagerd[4618]: kf.service.services: The desktop entry file "/usr/share/applications/org.freedesktop.Xwayland.desktop" has Type= "Application" but has no Exec field.
Oct 31 12:36:38 rapidus kactivitymanagerd[4618]: kf.service.services: The desktop entry file "/usr/share/applications/bookmarks.desktop" has Type= "Application" but has no Exec field.
Oct 31 12:36:38 rapidus kactivitymanagerd[4618]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
...
```

I've counted 684 of this warnings logged in 1 second, it looks like too much for me.
Comment 12 Nate Graham 2023-11-01 17:31:21 UTC
That commit is master-only; it hasn't been released yet. Are you testing with released packages, or unreleased code built from source?
Comment 13 Yaroslav Sidlovsky 2023-11-01 21:25:54 UTC
This code has been already included in latest kf5-kservice release (5.111.0), http://download.kde.org/stable/frameworks/5.111/kservice-5.111.0.tar.xz.

```
$ grep -Fr 'but has no Exec field'
kservice-5.111.0/src/services/kservice.cpp:        qCWarning(SERVICES) << "The desktop entry file" << entryPath() << "has Type=" << d->m_strType << "but has no Exec field.";
```
Comment 14 Nate Graham 2023-11-03 20:40:18 UTC
So it is!
Comment 15 Yaroslav Sidlovsky 2023-11-12 12:52:38 UTC
FYI: warning is still on it's place for version 5.112.0
Comment 16 zylsjsp 2023-11-15 08:42:53 UTC
Same issue still occurs in 5.112.0.
And I suppose that as defined in kservice.h, maybe removing the if block will be a simple fix. Only if `m_strExec` is properly set to an empty QString.
Comment 17 Jeffrey Walton 2023-11-15 13:20:29 UTC
(In reply to Matt M (gardotd426) from comment #5)
> (In reply to Ahmad Samir from comment #4)
> > I had read that comment; my previous message was sort of my reply to that,
> > creating a .desktop file that violates the desktop entry spec is wrong, and
> > then when tools that comply with the spec print errors about that, the
> > .desktop file should be fixed or removed.
> 
> The problem is that it (the .desktop file) inherently *can't* be fixed, but
> the .desktop file is required for Wayland in order to be able to actually
> show the right icon when a window is open. 
> 
> So basically it can't be fixed, and it can't be removed. The only/best
> solution I can  think of, because this is an extraordinarily edge case, is
> to add an exception to kservice that specifically ignores (or at least
> doesn't print any errors related to) the qemu.desktop file.

Whatever is happening, it is creating a lot of noise in the journals. Maybe the complaint can be throttled instead of hammering the log files:

# journalctl -r -b
...
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
Nov 15 07:30:35 raptor.home.arpa kactivitymanagerd[2027]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but has no Exec field.
...
Comment 18 David Faure 2023-11-15 13:39:41 UTC
Git commit ba4a641ee3bf4f0ccaa58b03dbdf88abf407b386 by David Faure.
Committed on 15/11/2023 at 14:39.
Pushed by dfaure into branch 'kf5'.

Remove warning about empty Exec field from KService::exec()

kactivitymanagerd calls exec() just to try and match the desktop file
for an executable, it's not actually about to execute the application.
So don't warn for e.g. qemu.desktop which only exists in order to
provide an icon for the qemu-$ARCH binary (on wayland).
FIXED-IN: 5.113

M  +0    -3    src/services/kservice.cpp

https://invent.kde.org/frameworks/kservice/-/commit/ba4a641ee3bf4f0ccaa58b03dbdf88abf407b386
Comment 19 Pussy Boots 2023-11-18 17:02:32 UTC
> FIXED-IN: 5.113

When this will be released?

Because here: https://invent.kde.org/frameworks/kservice/-/tags

There is a tag for v5.245.0, which is > 5.113, right?

But Arch Linux is still at 5.112
Comment 20 zylsjsp 2023-11-19 05:53:39 UTC
(In reply to Pussy Boots from comment #19)
> > FIXED-IN: 5.113
> 
> When this will be released?
> 
> Because here: https://invent.kde.org/frameworks/kservice/-/tags
> 
> There is a tag for v5.245.0, which is > 5.113, right?
> 
> But Arch Linux is still at 5.112

v5.113 will be released on branch kf5, current release is v5.112. v5.245 is on master branch, and similar bugs have already been fixed last month. If you can't wait till next month to apply the bugfix, either try kde-unstable repository or manually patch the source file and build the package on your own. ( PS I'm now using my own build with makepkg -e )