xdg-mime query default inode/directory

correctly gives me:


like I expect, and want it to.


xdg-open $HOME

Gives an error:

xdg-mime: mimetype argument missing
Try 'xdg-mime --help' for more information.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE (.*?)}/ at /usr/bin/run-mailcap line 528.
Warning: program returned non-zero exit code #66

...and opens Audacious.

I tried editing the run-mailcap line to escape the braces, and that gets rid of that error message. But it doesn't fix the problem. I still get "mimetype argument missing" and the wrong program opens.

I tried uninstalling Audacious, and it opens a different wrong program instead (git-cola and chrome).

I tried sudo apt-get install --reinstall xdg-utils and it didn't change anything.

edit: more information, the above described behavior happens in both Cinnamon and Gnome, but not in Lubuntu LXDE. In LXDE, the query gives nemo.desktop, and xdg-open does not produce any error messages in the terminal, but it opens PCManFM (not nemo).

Is that a clue to what is wrong or how to fix it?

  • just a thought , but are you sure the contents of $HOME are sane ? – Amias Jun 7 '16 at 15:17
  • just to check , what happens when you run the exec line from nemo.desktop ? – Amias Jun 7 '16 at 15:21
  • @amias some of nemo.desktop: Exec=nemo %U Icon=folder Terminal=false Type=Application StartupNotify=false Categories=GNOME;GTK;Utility;Core; MimeType=inode/directory;application/x-gnome-saved-search; nemo $HOME works as expected echo $HOME gives my user directory as expected – beauxq Jun 7 '16 at 15:52
  • 1
    did any of the answers work – William Oct 28 '16 at 15:42

I had exactly the same problem.
I could solve the problem by just install gvfs-bin (nothing more)...

sudo apt install gvfs-bin

I found this out, because in the log-files from user Amias is to read:
gvfs-open /home/amias

But gvfs-open was not installed on my system.

After installing gvfs-bin, it works!

To set a new file association (e.g use Nemo for folders), you can do:

gvfs-mime --set inode/directory nemo.desktop



Okay, it seems as though a patch was released for others having similar issues judging by this article: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810587

In this article the person was encountering:

"Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE (.*?)}/ at /usr/bin/run-mailcap line 528."

while running nmh which seems similar to your error message except for a different program. So I would recommend running:

sudo apt-get upgrade;sudo apt-get dist-upgrade

As the affected package might have an upgraded version available with the patch.

I hope this helps.

NOTE: This will upgrade all packages that can be upgraded (which is a good thing regardless) so don't be suprised if multiple packages want to upgrade.

  • "since 16.04 upgrade" means I already did the upgrade – beauxq May 31 '16 at 14:27
  • Sorry for the confusion. I meant since you upgraded to 16.04 xdg-open itself might have been upgraded (i.e. a new version of xdg-open released). The commands offered would then upgrade xdg-open to the newest supported version (if a newer version is available) and that newer version might have been patched as it was clearly an issue for more than just yourself. Once again sorry for the confusion. – Michael Knoll Jun 2 '16 at 3:30
  • I tried those upgrade commands and they didn't do anything. I also noted in the question that I already fixed the problem referenced by the bug you linked, and it didn't solve the problem of the wrong program opening. – beauxq Jun 4 '16 at 22:15
  • Oh sorry, well good luck with it as I'm out of ideas. Sorry for wasting your time. – Michael Knoll Jun 7 '16 at 23:35

xdg-open is a shell script so you can debug it with -x

bash -x /usr/bin/xdg-open $HOME

this gives me output like this

+ check_common_commands /home/amias
+ '[' 1 -gt 0 ']'
+ parm=/home/amias
+ shift
+ case "$parm" in
+ '[' 0 -gt 0 ']'
+ '[' -z '' ']'
+ '[' 0 -lt 1 ']'
+ xdg_redirect_output=' > /dev/null 2> /dev/null'
+ '[' x/home/amias '!=' x ']'
+ url=
+ '[' 1 -gt 0 ']'
+ parm=/home/amias
+ shift
+ case "$parm" in
+ '[' -n '' ']'
+ url=/home/amias
+ '[' 0 -gt 0 ']'
+ '[' -z /home/amias ']'
+ detectDE
+ '[' -n Unity ']'
+ case "${XDG_CURRENT_DESKTOP}" in
+ '[' x = x ']'
+ '[' x '!=' x ']'
+ '[' xthis-is-deprecated '!=' x ']'
+ DE=gnome
+ '[' xgnome = x ']'
+ '[' xgnome = x ']'
+ '[' xgnome = xgnome ']'
+ which gnome-default-applications-properties
+ DE=gnome3
+ '[' xgnome3 = x ']'
+ DEBUG 2 'Selected DE gnome3'
+ '[' -z '' ']'
+ return 0
+ case "${BROWSER}" in
+ case "$DE" in
+ open_gnome3 /home/amias
+ gvfs-open --help
+ gvfs-open /home/amias
+ '[' 0 -eq 0 ']'
+ exit_success
+ '[' 0 -gt 0 ']'
+ exit 0

This is from a working installation of xdg-open on 64bit 16.04.

I've shown you mine now you show me yours.


looking at your output i can see that open_generic_xdg_mime is failing to return a mime type and this is preventing the script from choosing the right service. A simple workaround would be to create a script called open_generic_xdg_mime and make it run 'file -i' against its input , this will give you the mime type but you will need to tidy the output a little with something like cut. let me know if you need a hand with that.

  • my output here: [link]paste.kde.org/pvpbuxzfj It might help to know: I tried uninstalling Audacious to see what it would do. Now it opens git-cola and then opens chrome. – beauxq Jun 7 '16 at 21:00
  • You have a lot more going on there , filetype doesn't get set and the script doesn't handle having no value for file type. Looks like a bug too me – Amias Jun 7 '16 at 21:10
  • from what you pasted it looks like the issue is that this command doesn't work - open_generic_xdg_mime – Amias Jun 10 '16 at 8:33

The problem is due to gvfs-info being deprecated.

Line 635 in xdg-mime is using gvfs-info for gnome. bash gvfs-info "$1" 2> /dev/null | grep standard::content-type | cut -d' ' -f4

I tried to re-evaluate that line manually here is the result:

gvfs-info ~/test.pdf|grep standard::content-type| cut -d' ' -f4
This tool has been deprecated, use 'gio info' instead.
See 'gio help info' for more info.

/usr/bin/gvfs-info: 10: [: ~/test.pdf: unexpected operator
/usr/bin/gvfs-info: 10: [: ~/test.pdf: unexpected operator

Then I tried using gio info:

gio info ~/test.pdf|grep standard::content-type| cut -d' ' -f4

So I temporarily changed the block for info_gnome() in xdg-mime to use gio info instead and bam, it worked!

631 info_gnome()                                                                     
632 {                                                                                
633     if gvfs-info --help 2>/dev/null 1>&2; then                                   
634         DEBUG 1 "Running gvfs-info \"$1\""                                       
635         gnomevfs-info "$1" 2> /dev/null | grep standard::content-type | cut -d' ' -f4 
636     elif gnomevfs-info --help 2>/dev/null 1>&2; then                             
637         DEBUG 1 "Running gnomevfs-info \"$1\""                                   
638         gnomevfs-info --slow-mime "$1" 2> /dev/null | grep "^MIME" | cut -d ":" -f 2 | sed s/"^ "//
639     else                                                                         
640         DEBUG 1 "Running gio info \"$1\""                                        
641         gio info "$1" 2> /dev/null | grep standard::content-type | cut -d' ' -f4 
642     fi                                                                           
643     if [ $? -eq 0 ]; then                                                        
644         exit_success                                                             
645     else                                                                         
646         exit_failure_operation_failed                                            
647     fi                                                                           
648 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.