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

apport-bug: Add /snap/bin to PATH for Firefox snap #2

Merged
merged 1 commit into from
Oct 3, 2022

Conversation

bdrung
Copy link
Collaborator

@bdrung bdrung commented Sep 12, 2022

On LXQt apport-bug is unable to open the Firefox snap at the very end of the process:

$ env -i apport-bug apport
[...]
Choices:
  1: Launch a browser now
  C: Cancel
Please choose (1/C): 1
/usr/bin/xdg-open: 882: firefox: not found
/usr/bin/xdg-open: 882: firefox: not found
xdg-open: no method available for opening 'https://bugs.launchpad.net/ubuntu/+source/apport/+filebug/d7ffa3e0-d46d-11ec-a167-40a8f03099c8?'

The Firefox snap provides /snap/bin/firefox. apport-bug sets the environment variable PATH, but does not include /snap/bin:

$ PATH=/usr/sbin:/usr/bin:/sbin:/bin xdg-open https://ubuntu.com
/usr/bin/xdg-open: 882: firefox: not found
/usr/bin/xdg-open: 882: firefox: not found
xdg-open: no method available for opening 'https://ubuntu.com'

xdg-open behaves differently depending on the desktop environment. On GMOME xdg-open calls gio open and successfully opens Firefox regardless of PATH, but on LXQt it tries to call firefox directly.

Bug: https://launchpad.net/bugs/1973470

@schopin-pro schopin-pro self-requested a review September 12, 2022 11:22
@schopin-pro
Copy link
Contributor

Codewise, LGTM. However, I just tried the following:

schopin@gandalf:~$ export PATH=/usr/bin:/bin
schopin@gandalf:~$ firefox
Command 'firefox' is available in '/snap/bin/firefox'
The command could not be located because '/snap/bin' is not included in the PATH environment variable.
firefox: command not found
schopin@gandalf:~$ xdg-open https://ubuntu.com
schopin@gandalf:~$ update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/cups/doc-root /usr/share/cups/doc-root none bind,ro 0 0): cannot create directory "/usr/share/cups/doc-root": permission denied
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/gimp/2.0/help /usr/share/gimp/2.0/help none bind,ro 0 0): cannot create directory "/usr/share/gimp/2.0": permission denied
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/libreoffice/help /usr/share/libreoffice/help none bind,ro 0 0): cannot create directory "/usr/share/libreoffice/help": permission denied
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/xubuntu-docs /usr/share/xubuntu-docs none bind,ro 0 0): cannot open directory "/var/lib": permission denied
Missing chrome or resource URL: resource://gre/modules/UpdateListener.sys.mjs

So xdg-open was perfectly capable of launching Firefox even if it isn't availabe in $PATH. I think we might actually be hitting a bug caused by the deb2snap migration?

I'm spinning up a fresh 22.04 VM to see how things are in a pristine env.

@codecov-commenter
Copy link

codecov-commenter commented Sep 13, 2022

Codecov Report

Merging #2 (59628c0) into main (a9f9593) will increase coverage by 0.00%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main       #2   +/-   ##
=======================================
  Coverage   79.29%   79.29%           
=======================================
  Files          77       77           
  Lines       17222    17222           
=======================================
+ Hits        13656    13657    +1     
+ Misses       3566     3565    -1     
Impacted Files Coverage Δ
tests/system/test_ui_gtk.py 97.68% <0.00%> (+0.15%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@murraybd
Copy link
Contributor

Given that the firefox snap is seeded in multiple flavors it is curious to me that this works in an Ubuntu desktop environment but not for Lubuntu.

@bdrung bdrung force-pushed the lp-1973470 branch 2 times, most recently from b307aca to b9fe4a4 Compare September 30, 2022 18:29
@bdrung
Copy link
Collaborator Author

bdrung commented Sep 30, 2022

xdg-open detects the desktop environment and behaves different depending on it. I reproduced the failure on LXQt and updated the merge request with more details.

@bdrung bdrung changed the title apport-bug: Add /snap/bin to PATH for firefox snap apport-bug: Add /snap/bin to PATH for Firefox snap Sep 30, 2022
On LXQt `apport-bug` is unable to open the Firefox snap at the very end
of the process:

```
$ env -i apport-bug apport
[...]
Choices:
  1: Launch a browser now
  C: Cancel
Please choose (1/C): 1
/usr/bin/xdg-open: 882: firefox: not found
/usr/bin/xdg-open: 882: firefox: not found
xdg-open: no method available for opening 'https://bugs.launchpad.net/ubuntu/+source/apport/+filebug/d7ffa3e0-d46d-11ec-a167-40a8f03099c8?'
```

The Firefox snap provides `/snap/bin/firefox`. `apport-bug` sets the
environment variable `PATH`, but does not include `/snap/bin`:

```
$ PATH=/usr/sbin:/usr/bin:/sbin:/bin xdg-open https://ubuntu.com
/usr/bin/xdg-open: 882: firefox: not found
/usr/bin/xdg-open: 882: firefox: not found
xdg-open: no method available for opening 'https://ubuntu.com'
```

`xdg-open` behaves differently depending on the desktop environment. On
GMOME `xdg-open` calls `gio open` and successfully opens Firefox
regardless of `PATH`, but on LXQt it tries to call `firefox` directly.

Bug: https://launchpad.net/bugs/1973470
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
Copy link
Contributor

@schopin-pro schopin-pro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@schopin-pro schopin-pro merged commit ffb7a0a into canonical:main Oct 3, 2022
@bdrung bdrung deleted the lp-1973470 branch October 4, 2022 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants