Skip to content

[bug] Linux desktop entry declares x-scheme-handler MimeType but Exec lacks %u — deep-link URLs silently dropped #15928

Description

@hz-xiaxz

Describe the bug

The Linux desktop entry generated by tauri-bundler declares MimeType=x-scheme-handler/<scheme> for configured deep-link schemes, but renders Exec={{exec}} without any field code (%u/%U). Per the freedesktop Desktop Entry specification, an entry whose Exec line has no field code is launched without the URL it was asked to open.

Consequence: when the OS resolves a deep link through the packaged desktop entry (browser → xdg-open / portal → x-scheme-handler association), the application is launched without the URL. The deep link silently vanishes — no error anywhere. For OAuth/OIDC flows this means the callback never reaches the app, and sign-in cannot complete through the system handler.

The runtime-registered handler that tauri-plugin-deep-link's register_all() writes to ~/.local/share/applications/<app>-handler.desktop does include %u, which masks the bug in dev setups. But desktop portals (e.g. xdg-desktop-portal-kde) exclude that NoDisplay=true entry from app choosers and may resolve to the packaged entry instead — which then drops the URL. This is how we hit it in production: KDE Plasma + Chrome, packaged deb, OAuth callback lost (reproduced and worked around here).

The template is unchanged on dev:
https://github.com/tauri-apps/tauri/blob/dev/crates/tauri-bundler/src/bundle/linux/freedesktop/main.desktop

Exec={{exec}}
...
{{#if mime_type}}
MimeType={{mime_type}}
{{/if}}

The entry declaring URL-scheme handling while dropping URLs is self-contradictory; the bundler already knows deep-link schemes are configured (it writes them into MimeType), so it has enough information to emit a field code.

Reproduction

  1. Configure plugins.deep-link.desktop.schemes = ["my-scheme"] and build a deb/rpm/AppImage.
  2. Install; confirm /usr/share/applications/<App>.desktop contains MimeType=x-scheme-handler/my-scheme and Exec=<binary> with no %u.
  3. gio open "my-scheme:/test?x=1" (or click such a link in a browser under a portal-based desktop).
  4. The app launches (or forwards via single-instance) with no URL in argvdeep_link().get_current() is empty.

Workaround: a custom desktopTemplate with Exec={{exec}} %u.

Expected behavior

The generated desktop entry passes the URL through, e.g. Exec={{exec}} %u (or an exec_arg variable computed by the bundler: %u when deep-link schemes are configured, %F/%U when file associations are configured, empty otherwise — mirroring what the NSIS/Windows and macOS bundlers already achieve via their native URL-activation mechanisms).

Full tauri info output

tauri-bundler 2.9.2 (via @tauri-apps/cli 2.11.2), tauri 2.x
Host: Arch Linux, KDE Plasma 6.7.4 (Wayland), xdg-desktop-portal-kde
Also verified against the template on the current `dev` branch.

Stack trace

No crash — the URL is silently dropped by the desktop launcher.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions