# Cannot open files or folders from within Slicer on Linux

**URL:** <https://discourse.slicer.org/t/cannot-open-files-or-folders-from-within-slicer-on-linux/30134>\
**Category:** Support\
**Created:** [June 20, 2023, 3:01am UTC](https://discourse.slicer.org/t/cannot-open-files-or-folders-from-within-slicer-on-linux/30134 "2023-06-20T03:01:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![benzwick](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/benzwick/32/80521_2.png) [@benzwick](https://discourse.slicer.org/u/benzwick)\
**Post date:** [June 20, 2023, 3:01am UTC](https://discourse.slicer.org/t/cannot-open-files-or-folders-from-within-slicer-on-linux/30134/1 "2023-06-20T03:01:11Z")

</div>

I’m using Slicer (stable 5.2.2 and preview 5.3.0-2023-06-17) on Debian 12 (bookworm) Linux with KDE. When I try to open a file using the “Edit” button in a ScriptedLoadableModule or a directory in e.g. the SlicerElastix module I get the following error and the file or directory is not opened:

```plaintext
[CRITICAL][FD] 19.06.2023 22:28:27 [] (unknown:0) - kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found

```

If I do the same using Slicer that I compiled myself I get the same error (with some additional errors), but the file or directory is opened:

```plaintext
[CRITICAL][FD] 19.06.2023 22:52:12 [] (unknown:0) - kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
[CRITICAL][FD] 19.06.2023 22:52:12 [] (unknown:0) - Hspell: can't open /usr/share/hspell/hebrew.wgz.sizes.
[CRITICAL][FD] 19.06.2023 22:52:12 [] (unknown:0) - kf.sonnet.clients.hspell: HSpellDict::HSpellDict: Init failed

```

The relevant lines in the code are these in ScriptedLoadableModule:

```python
    def onEditSource(self):
        filePath = slicer.util.modulePath(self.moduleName)
        qt.QDesktopServices.openUrl(qt.QUrl("file:///" + filePath, qt.QUrl.TolerantMode))

```

and these in SlicerElastix:

```python
  def onShowTemporaryFilesFolder(self):
    qt.QDesktopServices().openUrl(qt.QUrl("file:///" + self.logic.getTempDirectoryBase(), qt.QUrl.TolerantMode))

```

Does anyone have any ideas about what might be happening here?

---

<div class="post-metadata">

**Author:** ![benzwick](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/benzwick/32/80521_2.png) [@benzwick](https://discourse.slicer.org/u/benzwick)\
**Post date:** [June 20, 2023, 3:38pm UTC](https://discourse.slicer.org/t/cannot-open-files-or-folders-from-within-slicer-on-linux/30134/2 "2023-06-20T15:38:44Z")

</div>

Here is the output I get if I run the same commands in the Python console of the pre-built Slicer 5.3.0-2023-06-17 (the files do not open):

```plaintext
>>> qt.QDesktopServices.openUrl(qt.QUrl("file:///home/ben", qt.QUrl.TolerantMode))
True
>>> 
[FD] kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
>>> qt.QDesktopServices.openUrl(qt.QUrl("file:///home/ben/test.txt", qt.QUrl.TolerantMode))
True
>>> 
[FD] kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found

```

If I run the same commands using Slicer that I compiled myself I get the same output but the files are opened as expected.

The following `xdg-open` commands also work as expected even though they produce similar warnings/errors:

```plaintext
ben@p1:~$ xdg-open "/home/ben"
kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
kf.coreaddons: Expected a KPluginFactory, got a KIOPluginForMetaData
kf.coreaddons: Expected a KPluginFactory, got a KIOPluginForMetaData
kf.coreaddons: Expected a KPluginFactory, got a KIOPluginForMetaData
kf.coreaddons: Expected a KPluginFactory, got a KIOPluginForMetaData

ben@p1:~$ cat "/home/ben/test.txt"
hello

ben@p1:~$ xdg-open "/home/ben/test.txt"
kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
Hspell: can't open /usr/share/hspell/hebrew.wgz.sizes.
kf.sonnet.clients.hspell: HSpellDict::HSpellDict: Init failed

```

See also the discussion on the Debian forum [here](https://forums.debian.net/viewtopic.php?p=775312).

---

<div class="post-metadata">

**Author:** ![benzwick](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/benzwick/32/80521_2.png) [@benzwick](https://discourse.slicer.org/u/benzwick)\
**Post date:** [June 20, 2023, 3:40pm UTC](https://discourse.slicer.org/t/cannot-open-files-or-folders-from-within-slicer-on-linux/30134/3 "2023-06-20T15:40:30Z")

</div>

In today’s developer meeting @jcfr suggested to look at the following:

Relevant function on linux `QDBusMessage xdgDesktopPortalOpenUrl(const QUrl &url)`

In Qt 6: [https://github.com/qt/qtbase/blob/0235de994be7e04aca3456f1260b18313dd45b74/src/gui/platform/unix/qgenericunixservices.cpp#L204-L232](https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fqt%2Fqtbase%2Fblob%2F0235de994be7e04aca3456f1260b18313dd45b74%2Fsrc%2Fgui%2Fplatform%2Funix%2Fqgenericunixservices.cpp%23L204-L232&data=05%7C01%7Cbenjamin.zwick%40uwa.edu.au%7Ceea6a7781a91403550f808db719d46ff%7C05894af0cb2846d8871674cdb46e2226%7C0%7C0%7C638228692547253810%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=AZBDVCarN1rRBeVOEfv3YjTJMAhTtntLrBxkIDNY7Yo%3D&reserved=0)

May be related to [https://github.com/qt/qtbase/commit/fbfaf5d38b3455bb561e739271986be91a7c7169](https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fqt%2Fqtbase%2Fcommit%2Ffbfaf5d38b3455bb561e739271986be91a7c7169&data=05%7C01%7Cbenjamin.zwick%40uwa.edu.au%7Ceea6a7781a91403550f808db719d46ff%7C05894af0cb2846d8871674cdb46e2226%7C0%7C0%7C638228692547253810%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=iMrLqu5UKXZls8TCgjiOqkKnQ1w62AzOgzsd096rYwA%3D&reserved=0)

as well as XDG\_ACTIVATION\_TOKEN

---

<div class="post-metadata">

**Author:** ![benzwick](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/benzwick/32/80521_2.png) [@benzwick](https://discourse.slicer.org/u/benzwick)\
**Post date:** [June 20, 2023, 8:51pm UTC](https://discourse.slicer.org/t/cannot-open-files-or-folders-from-within-slicer-on-linux/30134/4 "2023-06-20T20:51:53Z")

</div>

I tested this again today on a fresh install of Debian 12 Bookworm in a VirtualBox machine. To test the behavior I clicked the “Open Slicer resource file” in the “General” Application Settings. In the GNOME desktop environment, the slicerrc.py file is opened with LibreOffice writer (although the software used can be configured by the user), but in the KDE/Plasma desktop environment, I get the same behavior as described above.

Also, my Debian installation and self-built Slicer are using Qt 5.15.8 (which is working) whereas the pre-compiled stable and preview Slicer are using 5.15.2 (which is NOT working).

I am guessing that this is a bug in Qt or KDE, which may have been fixed in Qt \> 5.15.2. I’ll list any relevant links here:

- [442721 – kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found](https://bugs.kde.org/show_bug.cgi?id=442721)
