Can't set Chromium as the default browser when BROWSER variable is defined

Bug #1823917 reported by Diego Cardinali on 2019-04-09
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
chromium-browser (Ubuntu)
Medium
Unassigned

Bug Description

STEPS TO REPRODUCE
 1. Install firefox
 2. Set `BROWSER=firefox`
 3. Open firefox and make sure it is the default browser
 4. Install chromium-browser
 5. Open chromium-browser and set it as the default browser
 6. Click on a link or use `xdg-open URL`

EXPECTED RESULTS
Link opens in chromium-browser

ACTUAL RESULTS
Link opens in firefox instead. Running chromium-browser from the terminal, when trying to change the default browser, the error "xdg-settings: $BROWSER is set and can't be changed with xdg-settings" appears. BROWSER, xdg-setting's default-web-browser, and xdg-mime's default for text/html remain unchanged. It's not possible to set the value of default-web-browser when the BROWSER variable is set. Yet, when making firefox default, the end result is that BROWSER is still set and default-web-browser and the default for text/html has changed.

AFFECTED VERSIONS
chromium-browser 73.0.3683.103-0ubuntu1

UPSTREAM BUG REPORTS
https://bugs.chromium.org/p/chromium/issues/detail?id=952569
https://github.com/lxqt/lxqt/issues/1513#issuecomment-482779833

Chris Guiver (guiverc) wrote :

To explore this bug

- booted a recent Lubuntu 19.04 install
- `xdg-open http://fridge.ubuntu.com` which caused firefox to open
- `sudo apt install chromium-browser`
- `chromium-browser http://fridge.ubuntu.com` & in settings found a 'make default' button which I clicked (a few times) noticing messages
- I exited chromium & executed the `xdg-open http://fridge..` & firefox re-started :(

guiverc@ultracrap:~$ chromium-browser http://fridge.ubuntu.com
[2393:2393:0410/112751.019896:ERROR:sandbox_linux.cc(364)] InitializeSandbox() called with multiple threads in process gpu-process.

(chromium-browser:2359): GLib-GIO-CRITICAL **: 11:28:25.806: g_dbus_proxy_new: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
xdg-settings: $BROWSER is set and can't be changed with xdg-settings
xdg-settings: $BROWSER is set and can't be changed with xdg-settings
xdg-settings: $BROWSER is set and can't be changed with xdg-settings

guiverc@ultracrap:~$ xdg-open http://fridge.ubuntu.com

Simon Quigley (tsimonq2) on 2019-04-10
affects: lxfind → lxqt-session (Ubuntu)
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in lxqt-session (Ubuntu):
status: New → Confirmed
Walter Lapchynski (wxl) wrote :

> xdg-settings: $BROWSER is set and can't be changed with xdg-settings

That's some telling info right there.

Some things to note:

 * In lxqt-config-session, in both Default Applications and Environment (Advanced) there is an option to set the BROWSER variable. It is set to firefox by default. It will come back if it is deleted (possibly a bug). Unlike TERM or EDITOR, which are part of the UNIX standard (http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_01), BROWSER is not always recognized by applications.

 * There is a Freedesktop Specification for MIME types (https://www.freedesktop.org/wiki/Specifications/mime-apps-spec/) that lxqt-config-file-associations interacts with. The xdg-utils (XDG = X Desktop Group, the former name of Freedesktop) tools interact with this. You can use them to find out which is your default browser via `xdg-mime query default text/html`. Similarly, `xdg-open` determines the MIME type of the argument it is given and passes it to the associated application.

 * There is also update-alternatives which allows you to assign different definitions of various types of generic programs. For example, you could easily select from different definitions for x-www-browser. I mention this for completeness, but it's not particularly relevant.

Now to prove this is not an issue with LXQt, consider this scenario:

 1. Load Lubuntu, which has firefox installed by default
 2. Install Opera
 3. Note that `echo $BROWSER` returns "firefox"
 4. Note that `xdg-mime query default text/html` returns "firefox.desktop"
 5. Note that `xdg-settings get default-web-browser` returns "firefox.desktop"
 6. Note `xdg-open http://ubuntu.com` opens in firefox
 7. Open qterminal and `echo 'http://ubuntu.com'`
 8. Note that holding down Ctrl and clicking on the URL opens it up in firefox
 9. Open up Opera and set it as the default browser
10. Note that `echo $BROWSER` returns "firefox"
11. Note that `xdg-mime query default text/html` returns "opera.desktop"
12. Note that `xdg-settings get default-web-browser` returns "opera.desktop"
13. Note `xdg-open http://ubuntu.com` opens in opera
14. Open qterminal and `echo 'http://ubuntu.com'`
15. Note that holding down Ctrl and clicking on the URL opens it up in opera

So why the problem with chromium-browser? Let's get back to that quote:

> xdg-settings: $BROWSER is set and can't be changed with xdg-settings

When you try to make chromium-browser default, it sees the BROWSER variable and just gives up, whereas Opera (and Firefox) ignores it and actually sets it. This error is actually from xdg-settings. It won't set default-web-browser while BROWSER exists. Yet, somehow firefox and opera both seem to deal with this. Therefore, I would call this chromium-browser's fault.

affects: lxqt-session (Ubuntu) → chromium-browser (Ubuntu)
Changed in chromium-browser (Ubuntu):
importance: Undecided → Medium
summary: - Can't set Chromium as the default browser
+ Can't set Chromium as the default browser when BROWSER variable is
+ defined
Walter Lapchynski (wxl) on 2019-04-10
description: updated
Olivier Tilloy (osomon) wrote :

Not sure about opera, but IIRC firefox doesn't use xdg-settings to set itself as the default browser.

chromium-browser relies on xdg-settings, which errors out when $BROWSER is set, and that's apparently intentional. So the bug here seems to be that $BROWSER is set in the first place. What purpose does that variable fulfill? As pointed out by Walter, it's not part of the UNIX standard.

Walter Lapchynski (wxl) on 2019-04-13
description: updated
Walter Lapchynski (wxl) wrote :

I will say, though, that there are many examples across various Linucies (that's the plural, right? ☺) suggesting to use the BROWSER variable to change the default browser. Case in point:
https://wiki.archlinux.org/index.php/Environment_Variables#Default_programs

And I might add another point: it's obvious that chromium-browser uses `xdg-settings` but I'm not sure what firefox uses, but the end result is that the `xdg-settings`, `xdg-mime` and `$BROWSER` values are all set appropriately. I will note, too, that `xdg-settings` results in a proportional change to `xdg-mime`.

I do think that setting BROWSER is problematic and it is contributing to the problem, but the fact that chromium-browser seems to be unique among other browsers in terms of lacking robustness to set itself as default regardless of circumstances. Therefore, I think the fault lies with it.

Changed in chromium-browser (Ubuntu):
status: Confirmed → Triaged
Walter Lapchynski (wxl) on 2019-04-13
description: updated
Walter Lapchynski (wxl) wrote :

I've also made the suggestion to LXQt to discontinue using `$BROWSER` and instead using `xdg-settings` as I've shown how even though chromium is unique in its robustness, there is still not a complete definition of "default browser" (including dealing with file associations/mimetypes and scheme handlers) by using `$BROWSER` alone, whereas `xdg-settings` just resolves everything.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers