xdg-open自16.04升级后停止工作

xdg-mime query default inode/directory 

正确地给了我:

 nemo.desktop 

就像我期望的那样,并希望它。

 xdg-open $HOME 

给出错误:

 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 

…并打开Audacious。

我尝试编辑run-mailcap行以逃避大括号,并删除该错误消息。 但它并没有解决问题。 我仍然得到“mimetype参数缺失”,错误的程序打开。

我尝试卸载Audacious,它会打开一个不同的错误程序(git-cola和chrome)。

我尝试了sudo apt-get install --reinstall xdg-utils ,它没有改变任何东西。

编辑:更多信息,上述行为发生在Cinnamon和Gnome,但不在Lubuntu LXDE。 在LXDE中,查询提供了nemo.desktop,而xdg-open在终端中不会产生任何错误消息,但它会打开PCManFM(而不是nemo)。

这是错误或如何修复的线索吗?

我有完全相同的问题。
我可以通过安装gvfs-bin来解决问题(仅此而已)……

sudo apt install gvfs-bin

我发现了这一点,因为来自用户Amias的日志文件是:
gvfs-open /home/amias

但是我的系统上没有安装gvfs-open。

安装gvfs-bin ,它可以工作!

要设置新的文件关联(例如,使用Nemo作为文件夹),您可以执行以下操作:

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

-干杯

好吧,似乎有一个补丁发布给其他有类似问题的人通过本文判断: https : //bugs.debian.org/cgi-bin/bugreport.cgi?video = 810587

在这篇文章中,这个人遇到了:

“正则表达式中未转义的左括号被弃用,在正则表达式中传递;标记为< - HERE in m /%{< - HERE(。*?)} / at / usr / bin / run-mailcap line 528。”

运行nmh时,除了不同的程序外,它似乎与您的错误消息类似。 所以我建议运行:

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

由于受影响的软件包可能具有修补程序可用的升级版本。

我希望这有帮助。

注意:这将升级所有可升级的软件包(无论如何都是一件好事),因此如果要升级多个软件包,请不要惊讶。

xdg-open是一个shell脚本,因此您可以使用-x对其进行调试

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

这给了我这样的输出

 + 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 

这是来自64位16.04的xdg-open的工作安装。

我告诉你我现在你告诉我你的。

编辑:

查看您的输出我可以看到open_generic_xdg_mime无法返回mime类型,这阻止脚本选择正确的服务。 一个简单的解决方法是创建一个名为open_generic_xdg_mime的脚本并使其对其输入运行’file -i’,这将为您提供mime类型,但您需要使用cut之类的东西整理输出。 如果你需要一只手,请告诉我。

问题是由于不推荐使用gvfs-info

xdg-mime中的第635行使用gvfs-info作为gnome。 bash gvfs-info "$1" 2> /dev/null | grep standard::content-type | cut -d' ' -f4

我尝试手动重新评估该行是结果:

 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 

然后我尝试使用gio info

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

所以我暂时更改了xdg-mime中的 info_gnome()块以使用gio info而不是bam,它有效!

 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 }