Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to open an URL in external browser on Ubuntu 22.10 with Firefox snap #86

Open
henryju opened this issue Jan 25, 2023 · 7 comments

Comments

@henryju
Copy link

henryju commented Jan 25, 2023

Hi,

I have recently switched to Ubuntu, and I discovered that my plugin is not able to open URLs in the external OS browser anymore.

Nothing happen when trying to open a URL, except this log (sorry, my OS is in french):

env: «https://the_url_i_tried_to_open»: Aucun fichier ou dossier de ce type

which can be translated by

env: «https://the_url_i_tried_to_open»: No file or folder of this type

We are using this API in our plugin:

PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(url));

Internally, this API is calling:

Program program = Program.findProgram("html");

that doesn't seem to work well in my case, possibly because of the fact Firefox is now installed as a snap package in Ubuntu. FYI, this is the result of the findProgram call:

image

I found a similar issue on Stack Overflow, but on my side Firefox seems to be correctly declared as default browser in the OS:

$ xdg-mime query default text/html
firefox_firefox.desktop

Interesting part of /var/lib/snapd/desktop/applications/firefox_firefox.desktop:

Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/firefox_firefox.desktop /snap/bin/firefox %u
@akurtakov
Copy link
Member

Snaps are Ubuntu specific technology so you may have to look into the code yourself to find a fix for it.

@henryju
Copy link
Author

henryju commented Jan 25, 2023

I don't think snap is the real problem here. To me, it looks like a problem with the way the default browser command is parsed from the .desktop file.

As you can see, the command in the Exec section starts with env, so I guess some code somewhere assumes the browser command will be the first "word" of this string.
Maybe somewhere inside g_app_info_get_default_for_type, but I could not find more.

@akurtakov
Copy link
Member

SWT doesn't parse desktop files but rather relies on gio to do so. It's pretty standalone part of SWT so one should be able to experiment with it fairly easy https://github.com/eclipse-platform/eclipse.platform.swt/blob/master/bundles/org.eclipse.swt/Eclipse%20SWT%20Program/gtk/org/eclipse/swt/program/Program.java#L114

@akurtakov
Copy link
Member

Note that g_app_info_get_default_for_type is not code maintained by SWT but comes from glib/gio and is invoked via JNI https://docs.gtk.org/gio/type_func.AppInfo.get_default_for_type.html . If you think this is the faulty part you should create snippet showing the issue and reporting it glib maintainers.

@henryju
Copy link
Author

henryju commented Jan 26, 2023

I am definitely not a C developer, but I did my best:
https://gitlab.gnome.org/GNOME/glib/-/issues/2901

@akurtakov
Copy link
Member

Thank you, it looks quite good report to me for Glib devs to act on.

@henryju
Copy link
Author

henryju commented Jan 26, 2023

So apparently, GLib developers are considering that SWT should not use g_app_info_get_executable to run a program. They are about to update the API documentation:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3240/diffs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants