containers / toolbox

Tool for interactive command line environments on Linux
https://containertoolbx.org/
Apache License 2.0
2.38k stars 208 forks source link

xdg-open not working #291

Open A6GibKm opened 4 years ago

A6GibKm commented 4 years ago

This is a continuation of #147, at the moment xdg-open is not working as intended,

$ /usr/bin/xdg-open somepdf.pdf 

gio: file:somepdf.pdf: No application is registered as handling this file
/usr/bin/xdg-open "https://www.google.cl"

gio: https://www.google.cl: Operation not supported

The expected behaviour should be to open using the host default application, a possible fix is to create a xdg-open script in your path with contents

#!/bin/sh
${TOOLBOX_PATH:+flatpak-spawn --host} /usr/bin/xdg-open "$@"
jdloft commented 4 years ago

So, if I understand it correctly, from #147, the flatpak-spawn method is the intended solution (even though it was split from flatpak, the name is just for historical purposes). I guess this script would have to be dropped in the image somewhere where it can override the builtin xdg-open.

poita66 commented 3 years ago

Having this script in the image would prevent a lot of headaches. I currently ran into this issue when trying to open links from VS Code running inside Toolbox. I'm happy to submit a PR if we can figure out where it should live.

adrm commented 3 years ago

This should work by default if toolbox is to be the required tool to do development work in a Fedora Silverblue or similar immutable systems. Many web development tools launch a browser when building, for example, and right now using toolbox with those tools throws really strange errors.

I am using the fix specified in the body of this issue, and it works for me, so at least a workaround is possible. Said that, I think it is pretty necessary for this to work by default.

lukateras commented 2 years ago

flatpak-xdg-open does work inside Toolbox, so the alternative fix is to use flatpak-xdg-utils as a drop-in replacement for xdg-utils specifically for Toolbox.

lukateras commented 2 years ago

For anyone still interested in this, here's my workaround (tested on Fedora Silverblue 35):

[yana@host ~]$ toolbox enter
[yana@toolbox ~]$ sudo dnf install flatpak-xdg-open
[yana@toolbox ~]$ sudo ln -s /usr/bin/flatpak-xdg-open /usr/bin/xdg-open
616b2f commented 5 months ago

For anyone still interested in this, here's my workaround (tested on Fedora Silverblue 35):

[yana@host ~]$ toolbox enter
[yana@toolbox ~]$ sudo dnf install flatpak-xdg-open
[yana@toolbox ~]$ sudo ln -s /usr/bin/flatpak-xdg-open /usr/bin/xdg-open

in Fedora Silverblue 39 this packages is called flatpak-xdg-utils now. Just in case someone has trouble to find it.

notfirefox commented 4 months ago

So we have a functioning workaround but not a proper upstream fix for it so far. Let me propose the following

Update the Fedora 39 container image

  1. Add flatpak-xdg-utils to the extra-packages file of the container image
  2. Link /usr/bin/xdg-open to /usr/bin/flatpak-xdg-open in the container file

~~There is however one thing I am not certain about. What happens when the xdg-utils package inside of the container gets updated, e.g. through sudo dnf upgrade. Does it overwrite /usr/bin/xdg-open and thus the link is gone?~~

The above concern is irrelevant, because the xdg-utils is not installed by default on the Fedora 39 image.

On a site note: Does it make sense to make this issue part of Project Pickle?