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

URLs open in Google Chrome instead of the user's preferred browser #24125

Closed
nic-obert opened this issue Feb 3, 2025 · 8 comments
Closed

URLs open in Google Chrome instead of the user's preferred browser #24125

nic-obert opened this issue Feb 3, 2025 · 8 comments
Labels
awaiting info Issue that needs more information from the user

Comments

@nic-obert
Copy link

nic-obert commented Feb 3, 2025

Summary

Zed defaults to opening URLs in Google Chrome instead of using the user's preferred browser and it doesn't seem to be a way of changing that.

Steps to trigger the problem:

  1. Click a link in Zed editor

Actual Behavior:
Zed opens URL in Google Chrome, which is not the user's preferred web browser.

Expected Behavior:
Zed should open the URL in the user's preferred web browser. It seems that Zed fails to recognize the user's preferred browser. Both xdg-open <url> and exo-open --launch WebBrowser <url> open the URL in Brave, which is my preferred web browser.

There is also no way of setting a preferred web browser to open URLs in Zed's settings.

Zed Version and System Specs

Zed: v0.171.6 (Zed)
OS: Linux X11 arcolinux unknown
Memory: 15.5 GiB
Architecture: x86_64
GPU: Intel(R) HD Graphics 530 (SKL GT2) || Intel open-source Mesa driver || Mesa 24.3.4-arch1.1

@probably-neb
Copy link
Contributor

probably-neb commented Feb 3, 2025

That's definitely weird. Under the hood we're just passing the request to open the URL to DBUS

But I don't know why our request and other xdg commands are choosing different browsers. Maybe they're prioritizing the $BROWSER env var and wherever our dbus command is going isn't?

Could you make sure that you get the same results when running the following commands?

$ xdg-mime query default x-scheme-handler/http
brave-browser.desktop

$ xdg-mime query default x-scheme-handler/https
brave-browser.desktop

$ xdg-settings get default-web-browser
brave-browser.desktop

I've personally had problems in the past where installing a new browser (specifically chrome) would set itself as the default handler in xdg for a bunch of stuff even when I didn't have it set as my default browser and am wondering if that's what's happening here

@probably-neb probably-neb added the awaiting info Issue that needs more information from the user label Feb 3, 2025
@yalikes
Copy link

yalikes commented Feb 4, 2025

I believe xdg-open and dbus are two independent system for default applications.

@probably-neb
Copy link
Contributor

I believe xdg-open and dbus are two independent system for default applications.

I don't believe this is true. DBUS is just the protocol for IPC that we are using to pass the openURI request to the XDG Desktop portal

@nic-obert
Copy link
Author

nic-obert commented Feb 5, 2025

@probably-neb the $BROWSER env variable is set to brave by .bashrc and echo $BROWSER outputs the string brave as expected. Note that brave is the name of the binary on $PATH.
All those xdg-* commands:

$ xdg-mime query default x-scheme-handler/http
brave-browser.desktop
$ xdg-mime query default x-scheme-handler/https
brave-browser.desktop
$ xdg-settings get default-web-browser
brave-browser.desktop

@probably-neb
Copy link
Contributor

Did you happen to run those commands in the Zed terminal? If not could you do so? This may be a $PATH issue

@nic-obert
Copy link
Author

@probably-neb all the xdg-* commands and echo $BROWSER in the Zed's built-in terminal have the same output as running them in my default terminal.
I don't know how it could be a $PATH issue, but here's my $PATH from the Zed terminal, if that can help

echo $PATH
/home/nic/.local/bin:/home/nic/.bin:/home/nic/.local/bin:/home/nic/.bin:/home/nic/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/opt/android-sdk/platform-tools:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/nic/.local/bin:/home/nic/.local/bin:/usr/include/python3.12:/home/nic/.local/bin:/usr/include/python3.12

The brave binary at /usr/bin/brave is on $PATH.

@probably-neb
Copy link
Contributor

We've had more than a few issues with $PATH unfortunately. I was wondering if maybe this was one of those and the xdg-portal was pulling the wrong thing due to the incorrect path but it doesn't seem like that's it.

The only other thing I can think to do is make sure the desktop portal settings are in order (usually in /usr/share/xdg-desktop-portal/ and ~/.config/xdg-desktop-portal) and making sure XDG is choosing the right desktop environment and portal. That will be up to you to figure out on your system.

Unfortunately if you can't find anything in the places I listed above or anywhere else I'm going to close this issue because as far as I can tell there isn't much we can do given that we just pass the open URI request to the XDG portal.

Feel free to open up a new discussion proposing the ability to directly set which browser links are opened in from within Zed, I believe that's possible with the DBUS api. We will allocate engineering resources towards the issue based on demand, surface area, complexity, etc. But I'm sure other people would love the ability to control which browser zed uses explicitly as well, so I think there's a pretty good chance we'd do this at some point.

@nic-obert
Copy link
Author

Ok, I solved the problem. Following this discussion, I could pinpoint the $HOME/.config/mimeapps.list configuration file. I opened it in a text editor and changed manually the applications bound to specific mime types, prioritizing brave-browser.desktop over google-chrome.desktop.

However, it's weird that setting mime handlers in xfce4-mime-settings seems to ignore this file, as it doesn't show mime handlers from this file. According to xfce4-mime-settings, no mime type was associated with Google Chrome, yet mimeapps.list had some mime types associated with google-chrome.desktop. Maybe that's an issue with xfce?

Anyway, as suggested, I'm gonna open a new discussion proposing the ability to set a preferred browser directly in Zed.
Thanks for your time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting info Issue that needs more information from the user
Projects
None yet
Development

No branches or pull requests

3 participants