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

Ubuntu snap packaged Firefox not starting with web-ext run #1696

Open
GrayedFox opened this issue Sep 3, 2019 · 10 comments
Open

Ubuntu snap packaged Firefox not starting with web-ext run #1696

GrayedFox opened this issue Sep 3, 2019 · 10 comments

Comments

@GrayedFox
Copy link

GrayedFox commented Sep 3, 2019

Is this a feature request or a bug?

Bug

The error is identical to #1607 however the cause is quite likely due to the app being installed via snap.

What is the current behavior?

Running web-ext run fails due to missing/inaccessible Firefox profile error.

web-ext run -p ~/snap/firefox/common/.mozilla/firefox/lis9gi8g.addons/ -v
[program.js][info] Version: 3.1.1
[program.js][debug] Discovering config files. Set --no-config-discovery to disable
[config.js][debug] Discovered config "/home/grayedfox/.web-ext-config.js" does not exist or is not readable
[config.js][debug] Discovered config "/home/grayedfox/github/multi-dict/web-ext-config.js" does not exist or is not readable
[program.js][info] Applying config file: ./package.json
[config.js][debug] Loading JS config file: "/home/grayedfox/github/multi-dict/package.json" (resolved to "/home/grayedfox/github/multi-dict/package.json")
[config.js][debug] Looking for webExt key inside package.json file
[config.js][debug] Config file /home/grayedfox/github/multi-dict/package.json did not define any options. Did you set module.exports = {...}?
[cmd/run.js][info] Running web extension from /home/grayedfox/github/multi-dict
[util/manifest.js][debug] Validating manifest at /home/grayedfox/github/multi-dict/manifest.json
[extension-runners/firefox-desktop.js][debug] Copying Firefox profile from /home/grayedfox/snap/firefox/common/.mozilla/firefox/lis9gi8g.addons/
[firefox/index.js][debug] Copying profile directory from "/home/grayedfox/snap/firefox/common/.mozilla/firefox/lis9gi8g.addons/"
[firefox/index.js][debug] Running Firefox with profile at /tmp/890adb6d-e660-4dbe-a2d2-d23a5a2237a5
[firefox/index.js][debug] Checking if remote Firefox port 6005 is available
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/index.js][debug] Executing Firefox binary: /snap/bin/firefox
[firefox/index.js][debug] Firefox args: -start-debugger-server 6005 -foreground -no-remote -profile /tmp/890adb6d-e660-4dbe-a2d2-d23a5a2237a5
[firefox/index.js][info] Use --verbose or open Tools > Web Developer > Browser Console to see logging
[firefox/remote.js][debug] Connecting to the remote Firefox debugger
[firefox/remote.js][debug] Connecting to Firefox on port 6005
[firefox/index.js][debug] Firefox stderr: /snap/firefox/253/bin/desktop-launch: line 174: /home/grayedfox/snap/firefox/common/.config/user-dirs.dirs: No such file or directory
[firefox/index.js][debug] Firefox stderr: cp: cannot create regular file '/home/grayedfox/snap/firefox/common/.config/': Not a directory
[firefox/index.js][debug] Firefox stderr: /snap/firefox/253/bin/desktop-launch: line 177: /home/grayedfox/snap/firefox/common/.config/user-dirs.dirs.md5sum: No such file or directory
[firefox/index.js][debug] Firefox stderr: /snap/firefox/253/bin/desktop-launch: line 177: /home/grayedfox/snap/firefox/common/.config/user-dirs.locale.md5sum: No such file or directory
[firefox/index.js][debug] Firefox stderr: Gtk-Message: Failed to load module "canberra-gtk-module"
...
[firefox/remote.js][debug] Retrying Firefox (250); connection error: Error: connect ECONNREFUSED 127.0.0.1:6005
[firefox/remote.js][debug] Connect to Firefox debugger: too many retries
[program.js][error] 
Error: connect ECONNREFUSED 127.0.0.1:6005
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)

[program.js][error] Error code: ECONNREFUSED

[program.js][debug] Command executed: run

What is the expected or desired behavior?

Firefox should open with copy of desired or default profile.

Version information (for bug reports)

  • Firefox version:
  • 68.0.2 (64-bit)
  • Mozilla Firefox Snap for Ubuntu
  • canonical-002 - 1.0
node --version && npm --version && web-ext --version
v10.16.3
6.11.2
3.1.1
@GrayedFox
Copy link
Author

I can confirm the uninstalling the snap package and installing via aptitude solved the problem. I debugged it a little bit - the location that web-ext is searching for profiles in is in fact correct. I also tried using the Profile Manager to create a new addons profile and specified that one using the -p switch and got the same error (demonstrated in the log).

For whatever reason, web-ext seems unable to copy profiles created using a snap installed Firefox (it can still see them). Running with sudo had the same effect.

@Junkern
Copy link

Junkern commented Nov 4, 2020

I can confirm this, I get the exact same error. I am kinda hesistant to uninstall firefox as it is my main browser (e.g. stored passwords). Would be great to find a workaround or bugfix for this.

Versions:

Firefox 82.0.2 (Mozilla Firefox Snap for Ubuntu, canonical-002 - 1.0)

node --version && npm --version && web-ext --version
10.20.1
6.14.4
5.3.0

@rpl
Copy link
Member

rpl commented Nov 5, 2020

I should come back to this and dig a bit more to plan a proper fix, but from what I recall the underlying issue is related to the access to the fact that the snap packaged firefox is confined and can only access what it has explicit permissions for.

By default the snap packaged firefox binary does seem to have access to the home directory but not to the system /tmp directory (and I recall that the flatpack package does also have a pretty similar issue), which is clearly on purpose and there is no permission to grant access to /tmp.

As an additional confirmation that this is the actual underlying issue, I tried to explicitly point the temporary directory used by web-ext to a directory inside the user home does fix the issue for me locally by setting the TMPDIR environment var on the web-ext command, e.g.:

$ mkdir ~/tmp-dir
$ TMPDIR=~/tmp-dir/ web-ext run ... 

@joelpurra
Copy link
Contributor

joelpurra commented Oct 20, 2021

Ubuntu 21.10, released about a week ago, automatically replaces apt Firefox with snap Firefox. This is the official Mozilla+Canonical way to use Firefox on Ubuntu.

which firefox 
/snap/bin/firefox
firefox --version
Mozilla Firefox 93.0
web-ext --version
6.5.0

Using web-ext run on Ubuntu 21.10:

Profile missing

Your Firefox profile cannot be loaded. It may be missing or inaccessible.

Using web-ext run with $TMPDIR in $HOME:

Close Firefox

Firefox is already running, but is not responding. To use Firefox, you must first close the existing Firefox process, restart your device, or use a different profile.

The message is the same even if Firefox was not running. Setting web-ext run --firefox-profile does not seem to help; perhaps Firefox doesn't get that far.

Is there another combination of environment variables and arguments which works?


Regarding picking a snap-accessible temporary directory on Ubuntu, I would suggest ${XDG_CACHE_HOME}/web-ext from the XDG Base Directory Specification. See libraries such as xdg-basedir or cross-platform env-paths.

@fadyanwar
Copy link

Hi, just encountered same issue and found this thread via search. Any updates on this issue? Thanks!

@pablooliva
Copy link

As an alternative, if your main browser is the Snap version of Firefox, you can install Firefox Developer Edition (https://dev.to/harrsh2124/how-to-setup-firefox-developer-edition-on-ubuntu-4inp) and then run web-ext by pointing it to this new install, such as web-ext run --firefox=/opt/firefox/firefox

@minfrin
Copy link

minfrin commented Sep 11, 2022

I'm in dependency hell on a Raspberry Pi due to web-ext breakage with snap. Does anyone know of a combination of web-ext and firefox (not firefox-esr) that works?

@sealor
Copy link

sealor commented Sep 24, 2022

@rpl Thanks!

Additionally, I have to run Firefox on Wayland with Ubuntu 22.04:
MOZ_ENABLE_WAYLAND=1 TMPDIR=~/tmp web-ext run

@Sharcoux
Copy link

MOZ_ENABLE_WAYLAND=1 TMPDIR=~/tmp web-ext run didn't help for me on Ubuntu 22.04, nor any of the other solution.

If I run web-ext with --firefox-profiles option, I get this error. If I manually fix the path in the firefox-profile-js lib, I get a dialog box telling me: Your Firefox profile cannot be loaded. It may be missing or inaccessible.. I don't know how to go further.

@pieterjongsma
Copy link

pieterjongsma commented May 6, 2024

For anyone this isn't clear yet for: the issue seems to be with snap-installed firefox. web-ext creates a temporary firefox profile folder in /tmp. Also when you use an existing profile directory or name, web-ext will copy this profile to /tmp. (Note that you can see this by using --verbose.) Snap however doesn't allow apps to access /tmp outside a designated temporary directory created for the app. In short, to use web-ext right now, you'll need firefox installed differently than through snap.

amd64/i386

If you're on a regular amd64/i386 architecture, one solution would be to uninstall the snap-installed firefox and install it through Mozilla's repo's (in case of Debian/Ubuntu).

To uninstall (Ubuntu):

apt remove firefox # This doesn't seem to remove the snap
snap remove firefox

To install: https://support.mozilla.org/en-US/kb/install-firefox-linux#w_install-firefox-deb-package-for-debian-based-distributions

aarch64

If you're unlucky enough to be running on an ARM processor (like me), Mozilla is not yet providing regular packages for ARM. (The one you're using is probably provided by your distro, like Ubuntu does.) Luckily, Mozilla did just start building Firefox-nightly for ARM. Maybe, by the time you read this, regular releases are also available through the repo. In that case, you can just follow the instructions for amd64 above.

Personally I'm using the nightly builds for now. Instead of apt install firefox it's apt install firefox-nightly (you can leave regular firefox installed for normal use).

To make web-ext use the nightly build which has a different name, I created a shim:

#!/bin/bash
firefox-nightly "$@"

saved to a folder in PATH as just firefox, with higher priority than the normal firefox install. This works, although it is far from simple.

Then run web-ext with the --firefox=nightly option.

Of course, you could also build Firefox for ARM yourself, but this is quite cumbersome as well.

Hope this helps someone!

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

10 participants