Bug 419144 - kde-open5 fails to open custom mimetypes when ~/.local/share/mime/application is a symlink
Summary: kde-open5 fails to open custom mimetypes when ~/.local/share/mime/application...
Status: REPORTED
Alias: None
Product: kde-cli-tools
Classification: Plasma
Component: general (show other bugs)
Version: 5.12.8
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Aleix Pol
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-23 14:21 UTC by Nathaniel Beaver
Modified: 2021-08-25 19:41 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Files to replicate the bug. (2.75 KB, application/zip)
2020-03-23 14:21 UTC, Nathaniel Beaver
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nathaniel Beaver 2020-03-23 14:21:01 UTC
Created attachment 126968 [details]
Files to replicate the bug.

SUMMARY
kde-open5 fails with custom mimetypes when ~/.local/share/mime/application is a symbolic link pointing to the directory containing the mimeinfo files

STEPS TO REPRODUCE

Github repo for this purpose:

https://github.com/nbeaver/kde-custom-mimetype-bug

A zip file with the necessary files is also attached.

Manual steps for completeness:

$ cat fcyzqrpw.desktop 
[Desktop Entry]
Version=1.0
Type=Application
Name=FCYZQRPW handler
Comment=Handles FCYZQRPW files
TryExec=xedit
Exec=xedit %F
MimeType=application/x-fcyzqrpw

$ cat x-fcyzqrpw.xml 
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    <mime-type type="application/x-fcyzqrpw">
        <comment>FCYZQRPW file</comment>
        <glob pattern="*.fcyzqrpw"/>
    </mime-type>
</mime-info>

$ cat example.fcyzqrpw 
This is an example fcyzqrpw file.

Commands to install mimetype, symlink the directory, and open the example file:

    xdg-mime install --mode user x-fcyzqrpw.xml
    desktop-file-install --dir=~/.local/share/applications/ fcyzqrpw.desktop
    chmod +x ~/.local/share/applications/fcyzqrpw.desktop
    xdg-mime default fcyzqrpw.desktop application/x-fcyzqrpw
    update-desktop-database ~/.local/share/applications
    update-mime-database ~/.local/share/mime
    mv ~/.local/share/mime/application ~/.local/share/mime/application.real
    ln -s -r ~/.local/share/mime/application.real ~/.local/share/mime/application
    kde-open5 example.fcyzqrpw

OBSERVED RESULT

kde-open5 shows a "Choose Application - KIO Client" window and can't save any persistent default application.

EXPECTED RESULT

kde-open5 opens the example file in xedit

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Linux onyx 5.3.0-40-generic #32~18.04.1-Ubuntu SMP Mon Feb 3 14:05:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
(available in About System)
KDE Plasma Version: 5.12.9
KDE Frameworks Version: 5.44.0
Qt Version: 5.9.5

ADDITIONAL INFORMATION

The example given is intentionally artificial, but this applies to any custom mimetype. I first noticed it when trying to open Mathematica notebooks in Dolphin.

It may seem unusual that ~/.local/share/mime/application is a symbolic link, but this is common for symlink configuration managers such as GNU stow.

https://www.gnu.org/software/stow/

The workaround is simply to dereference the symlink and make ~/.local/share/mime/application and parent directories not be a symlink (i.e. don't use GNU stow).

Note that other candidates for xdg-open such as gio and exo-open do not suffer from this bug.

This might ultimately be a bug in frameworks-kio or frameworks-kservice, but I'm reporting this to kde-cli-tools since it can be be replicated with kde-open5. (It can also be replicated with Dolphin.)

$ kde-open5 --version
kioclient 5.12.8
$ apt-cache policy kde-cli-tools libkf5kiocore5 libkf5service5
kde-cli-tools:
  Installed: 4:5.12.8-0ubuntu0.1
  Candidate: 4:5.12.8-0ubuntu0.1
  Version table:
 *** 4:5.12.8-0ubuntu0.1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages
        100 /var/lib/dpkg/status
     4:5.12.4-0ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
libkf5kiocore5:
  Installed: 5.44.0-0ubuntu1
  Candidate: 5.44.0-0ubuntu1
  Version table:
 *** 5.44.0-0ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
        100 /var/lib/dpkg/status
libkf5service5:
  Installed: 5.44.0-0ubuntu1
  Candidate: 5.44.0-0ubuntu1
  Version table:
 *** 5.44.0-0ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
        100 /var/lib/dpkg/status