9
xdg-mime query default inode/directory

correctly gives me:

nemo.desktop

like I expect, and want it to.

But

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?

beauxq
  • 211

4 Answers4

4

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

-Cheers

Ben
  • 752
1

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.

Michael Knoll
  • 83
  • 1
  • 11
1

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 '' ']'
+ unset XDG_UTILS_DEBUG_LEVEL
+ '[' 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
+ unset GREP_OPTIONS
+ '[' -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.

edit:

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.

Amias
  • 5,359
1

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
application/pdf

Then I tried using gio info:

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

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 }
ExistMe
  • 121