Skip to content

Firefox opens directories in RawTherapee ... or a tale of colliding assumptions

Internet

After installing RawTherapee, a raw photo to jpg image converter, on my Kubuntu 13.04 desktop, Mozilla Firefox started to open the Downloads directory in ... RawTherapee. Gosh. Now that's what you'd want to browse a downloads folder with.

Update-alternatives did not help as RawTherapee is not managed by the Debian alternatives system. Hm, xdg-open still works as intended and opens dolphin.

Asking Google turns up many not working solution proposals. Hm.

Firefox: Context menu (right click) -> Open Containing Folder

But, searching the collective memory is not completely useless. There is a solved bug report on the RawTherapee bug tracker that explains the issue. The .desktop file RawTherapee installs contains inode/directory as a supported mime type. Well, that's technically correct but makes no sense in the way mime associations are used. Thankfully the bug reporter was able to convince the developer of this and get this fixed for future RawTherapee releases.

So option 1: edit /usr/share/applications/rawtherapee.desktop and remove the inode/directory entry from the MimeType=-line. Then regenerate the various mimetype caches.

This still bears the question why Firefox does not use the inode/directory entry from dolphin.desktop. Also, the next update from Debian/Ubuntu will probably overwrite the fixed rawtherapee.desktop file again as the patch from the Rawtherapee developer will only be included on new releases (and these may or may not be backported to Debian/Ubuntu). So you'd need to copy that fixed rawtherapee.desktop file to ~/.local/share/applications/ or the like.

Option 2: find out what the real issue is...

Let's run:

strace -o/var/tmp/trace /usr/bin/firefox

Now browsing through the resulting /var/tmp/trace you'll find:

[...]
... this is the downloaded file where context menu (right click) -> "Open Containing Folder" has been clicked:
stat("/home/dlange/Downloads/vpngate_jawws.opengw.net_udp_1194.ovpn", {st_mode=S_IFREG|0664, st_size=8702, ...}) = 0
... and now Firefox goes to search and find which application to open a directory with:
stat("/home/dlange/.local/share/applications/mimeinfo.cache", 0x7fff4e864400) = -1 ENOENT (No such file or directory)
stat("/home/dlange/.local/share/applications/mimeinfo.cache", 0x7fff4e8644e0) = -1 ENOENT (No such file or directory)
stat("/home/dlange/.local/share/applications/defaults.list", 0x7fff4e864420) = -1 ENOENT (No such file or directory)
stat("/home/dlange/.local/share/applications/defaults.list", 0x7fff4e8644e0) = -1 ENOENT (No such file or directory)
stat("/home/dlange/.local/share/applications/mimeapps.list", {st_mode=S_IFREG|0600, st_size=644, ...}) = 0
stat("/usr/share/applications/mimeinfo.cache", {st_mode=S_IFREG|0644, st_size=35278, ...}) = 0
stat("/usr/share/applications/defaults.list", {st_mode=S_IFREG|0644, st_size=9976, ...}) = 0
stat("/usr/share/applications/mimeapps.list", 0x7fff4e864420) = -1 ENOENT (No such file or directory)
stat("/usr/share/applications/mimeapps.list", 0x7fff4e8644e0) = -1 ENOENT (No such file or directory)
stat("/usr/share/kde-plasma/applications/mimeinfo.cache", 0x7fff4e864400) = -1 ENOENT (No such file or directory)
stat("/usr/share/kde-plasma/applications/mimeinfo.cache", 0x7fff4e8644e0) = -1 ENOENT (No such file or directory)
stat("/usr/share/kde-plasma/applications/defaults.list", 0x7fff4e864420) = -1 ENOENT (No such file or directory)
stat("/usr/share/kde-plasma/applications/defaults.list", 0x7fff4e8644e0) = -1 ENOENT (No such file or directory)
stat("/usr/share/kde-plasma/applications/mimeapps.list", 0x7fff4e864420) = -1 ENOENT (No such file or directory)
stat("/usr/share/kde-plasma/applications/mimeapps.list", 0x7fff4e8644e0) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/applications/mimeinfo.cache", 0x7fff4e864400) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/applications/mimeinfo.cache", 0x7fff4e8644e0) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/applications/defaults.list", 0x7fff4e864420) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/applications/defaults.list", 0x7fff4e8644e0) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/applications/mimeapps.list", 0x7fff4e864420) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/applications/mimeapps.list", 0x7fff4e8644e0) = -1 ENOENT (No such file or directory)
stat("/usr/share/applications/mimeinfo.cache", {st_mode=S_IFREG|0644, st_size=35278, ...}) = 0
stat("/usr/share/applications/defaults.list", {st_mode=S_IFREG|0644, st_size=9976, ...}) = 0
stat("/usr/share/applications/mimeapps.list", 0x7fff4e864420) = -1 ENOENT (No such file or directory)
stat("/usr/share/applications/mimeapps.list", 0x7fff4e8644e0) = -1 ENOENT (No such file or directory)
... the various mimetype caches are done, now for the individual .desktop files:
open("/home/dlange/.local/share/applications/nautilus-folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dlange/.local/share/applications/nautilus/folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dlange/.local/share/applications/nautilus-folder/handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/nautilus-folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/nautilus/folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/nautilus-folder/handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/kde-plasma/applications/nautilus-folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/kde-plasma/applications/nautilus/folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/kde-plasma/applications/nautilus-folder/handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/applications/nautilus-folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/applications/nautilus/folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/applications/nautilus-folder/handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/nautilus-folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/nautilus/folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/nautilus-folder/handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dlange/.local/share/applications/dolphin.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/dolphin.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/kde-plasma/applications/dolphin.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/applications/dolphin.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/dolphin.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dlange/.local/share/applications/nautilus-folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dlange/.local/share/applications/nautilus/folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dlange/.local/share/applications/nautilus-folder/handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/nautilus-folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/nautilus/folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/nautilus-folder/handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/kde-plasma/applications/nautilus-folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/kde-plasma/applications/nautilus/folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/kde-plasma/applications/nautilus-folder/handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/applications/nautilus-folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/applications/nautilus/folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/applications/nautilus-folder/handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/nautilus-folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/nautilus/folder-handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/nautilus-folder/handler.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dlange/.local/share/applications/rawtherapee.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/applications/rawtherapee.desktop", O_RDONLY) = 44
... o.k., it found a .desktop file to read
fstat(44, {st_mode=S_IFREG|0644, st_size=1101, ...}) = 0
read(44, "[Desktop Entry]\nType=Application"..., 4096) = 1101
read(44, "", 4096)                      = 0
close(44)                               = 0
access("/usr/local/sbin/rawtherapee", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/bin/rawtherapee", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/sbin/rawtherapee", X_OK)   = -1 ENOENT (No such file or directory)
access("/usr/bin/rawtherapee", X_OK)    = 0
... Firefox goes on to start /usr/bin/rawtherapee
[...]

You easily see the massive amount of locations Firefox tries to find a suitable mime entry. If you look carefully, you can also spot the issue.

open("/usr/share/applications/dolphin.desktop", O_RDONLY) = -1 ENOENT (No such file or directory)

indicates failure, the dolphin.desktop file was not found. Wait a moment, I use dolphin every day. It's there. But it's installed in /usr/share/applications/kde4/dolphin.desktop. Ouch! So Firefox does not search the applications-dir recursively nor does it have applications/kde4 in its search path for .desktop files.

Symbolic link for dolphin.desktop

So a solution is easy to implement now. We need to make sure Firefox finds the dolphin.desktopfile before it finds the rawtherapee.desktop file:

cd /usr/share/applications/
sudo ln -vs kde4/dolphin.desktop . # notice the dot
 

Now the dolphin.desktop file will be found earlier in the process and Firefox will open the Downloads folder in Dolphin again.

But why?

The underlying issue revealed here is one that is very common in loosely coupled cooperation situations.
People rely on an assumption, on an interpretation of a (vaguely formulated) standard, on what's (often wrongly) thought to be best practices.
And the differences in interpretation manifest themselves right into a breakage.

Firefox is developed as a Gnome application. The developers adhere to the Freedesktop standards, e.g. the one covering .desktop files. Now sadly so, this document does not describe what to do with the .desktop files, it describes the what but not the how.

Apparently the Firefox developers assumed reading /usr/share/applications/*.desktop (and a few other locations like that, see the strace dump above) was good enough. They wanted to save the effort of recursing all underlying directories which is a potentially very slow (expensive) process. The Gnome documentation on desktop files does not indicate the directories need to be recursively searched. It reads "Place [the .desktop] file in the /usr/share/applications directory so that it is accessible by everyone, or in ~/.local/share/applications if you only wish to make it accessible to a single user." So it's easy to assume placing and searching files in the top-level directory is sufficient.

Now the KDE folks lead the definition of the Freedesktop Menu specification and that one even gives an example for their friends from Gnome: "GNOME applications [install] desktop files [...] in datadir/applications/ or it could install desktop files in a datadir/applications/gnome subdirectory."

The KDE folks assumed that the joint Freedesktop proposal was sufficient to use a clean /usr/share/applications/kde4/ to store their (in my case 151) .desktop files from all KDE apps as everybody would be recursing the applications directory now.

The Menu specification from Freedesktop states: "If the directory contains sub-directories then these sub-directories should be (recursively) scanned as well."

Well, should is not must. RFC2119 defines:

MUST
This word, or the terms "REQUIRED" or "SHALL", mean that the definition is an absolute requirement of the specification.
SHOULD
This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.

So this is a case of conflicting assumptions facilitated by an insufficiently strict standard.

Update:

02.06.2013: a user in ##linux on freenode reported the same issue with audacious. Here again the mimetype inode/directory claimed by audacious is the culprit. In this case just copying Thunar-folder-handler.desktop to ~/.local/share/applications/ and running update-desktop-database ~./local/share/applications/ solved the issue.

21.07.2014: Recently somehow an application/octet-stream=bluefish.desktop; ended up in my desktop's ~/.local/share/applications/mimeapps.list. Probably because I told Firefox to open some other file that was served as application/octet-stream (but was a text file by content and file extension) in Bluefish. Apparently it does not save that connection bound to the file extension but bound to the (wrong and generic) mime-type. This in turn leads to Firefox wanting to open .pdf files downloaded from the net with that generic mime-type in ... Bluefish now. Removing the application/octet-stream=bluefish.desktop; line from the mimeapps.list file solves that issue.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

Jarrod Shumaker on :

Hi there, I have been searching and searching for a fix to my problem. Yours seems to give me the most hope as it allows me to see what exactly FireFox is "trying" to do when I click, "Open Containing Folder".

My issue is: "Open Containing Folder" it opens in Nautilus, I would prefer it open in Dolphin. I have changed every known mimeapps.list/defaults.list to contain the relevant entries of: application/x-directory=kde4-dolphin.desktop x-directory/normal=kde4-dolphin.desktop

I've also confirmed that in the UI settings, Dolphin is first and removed other entries (of which Nautilus is not one) which did update my defaults.list but did not fix my problem.

After much googling I landed on your page but after performing strace I did not find any entries throughout the entire log for nautilus OR dolphin. I then searched for anything that started with, "open("/usr/share/applications/", this turned up 26 hits but all of them read as: mimeinfo.cache", 0_RDONLY) = 31 within the results were hits for things other than mimeinfo, ex. kde4-kwrite.desktop but it's unclear to me whether or not those other hits are relevant. Interesting note is that there are several, "stat" entries above the "open" entries that read: stat("/usr/local/share/applications/defaults.list", 0x7fff977522b0) = -1 ENOENT (No such file or directory) stat("/usr/local/share/applications/mimeapps.list", 0x7fff977522b0) = -1 ENOENT (No such file or directory)

All of this said I would be curious if you had any other ideas as to why my strace is not turning up any nautilus or dolphin results.

Daniel Lange on :

Pastebin the whole strace log and join ##linux on freenode IRC. Ask in the channel for support. I'm sure people there (including me if I'm around at the time) will be able to help you debug this interactively.

Add Comment

Markdown format allowed
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.