karma-firefox-launcher icon indicating copy to clipboard operation
karma-firefox-launcher copied to clipboard

Firefox snap has no access to /tmp profiles path

Open benkuly opened this issue 2 years ago • 9 comments

When running Firefox as snap, he does't have access to the /tmp directory and therefore firefox cannot load the profile. It was really hard to debug, because FIrefox doesn't fail to start in -headless mode and therefore there is just a karma timeout.

FIrefox solves that by putting tmp files into ~/Downloads/firefox.tmp/.

benkuly avatar Dec 23 '21 10:12 benkuly

I did not understand the problem. Can you clarify and provide repro steps?

jginsburgn avatar Jan 08 '22 07:01 jginsburgn

Repro: Install Firefox as snap (linux) and remove other installed Firefox. When running as snap, Firefox has very limited access to the filesystem, as described in the issue description.

benkuly avatar Jan 08 '22 08:01 benkuly

Create a file in /tmp, say using xfce4-screenshooter

$ ls -l /tmp/Screenshot_2022-08-22_11-19-13.jpg 
-rw-rw-r-- 1 me mygroup 87400 Aug 22 11:19 /tmp/Screenshot_2022-08-22_11-19-13.jpg

Try to open the file in Firefox

file:///tmp/Screenshot_2022-08-22_11-19-13.jpg

Reports the following

File not found
Firefox can’t find the file at /tmp/Screenshot_2022-08-22_11-19-13.jpg.
    Check the file name for capitalisation or other typing errors.
    Check to see if the file was moved, renamed or deleted.

Potentially firefox in a snap thinks /tmp is stored in ~/Downloads/firefox.tmp

firefox prevents access to folders like /var, /etc, /opt. but with /tmp it fakes it. Going to "/" does not show all directories either -- creating a root directory "/test", and even chmod/chowning to the user, does not update. This might be because firefox snapshots it on bootup?

Firefox does allow access to /var/tmp, which is updated.

It's inconsistent and not very well explained.

isostatic avatar Aug 22 '22 10:08 isostatic

Any fix for this? Running into it in Karma+Firefox now, Ubuntu 22.04, Firefox 104.0.2:

image

perry-mitchell avatar Sep 08 '22 17:09 perry-mitchell

What's your karma config for launching Firefox?

oyejorge avatar Oct 03 '22 19:10 oyejorge

Hi. So this seems to be the issue I am facing after all.

Unfortunately it seems Firefox from apt is also broken to some extent, just differently so no longer a workaround :( https://askubuntu.com/questions/1435994/broken-mozilla-firefox-no-text-displays-font-issue

Would be really nice if https://github.com/karma-runner/karma-firefox-launcher/pull/47 could be fixed/merged.

Thanks in advance.

ipbc-dev avatar Oct 18 '22 10:10 ipbc-dev

Would be really nice if #47 could be fixed/merged.

I went to go and update #47 for merging but I noticed we already have the profile option for specifying the path to an existing profile. Is that enough? Or do we also need a profileName option for loading a profile by name instead?

birtles avatar Oct 19 '22 00:10 birtles

Many thanks for your reply. I confirm the profile option works correctly.

        customLaunchers: {
            'FirefoxHeadless': {
                base: 'Firefox',
                flags: [ '-headless' ],
                profile: require('path').join(__dirname, 'tmp'),
            }
        },

I leave this as an exercise to a future reader to define a good, possibly random, location and clean up after test suite completes, if necessary. This should make us able to workaround this annoying bug that Ubuntu snap has.

ipbc-dev avatar Oct 19 '22 11:10 ipbc-dev

Firefox does allow access to /var/tmp, which is updated.

Cheers for the workaround! I like to have my downloads saved to /tmp, which I've been unable to do on Firefox snap, but /var/tmp is the next best thing. :)

wleoncio avatar Mar 07 '23 13:03 wleoncio