Skip to content

[BUG] Running Nightly as root in a regular user's session is not supported. #6500

Closed

Description

Running playwright automation in Github CI using docker image fails for Firefox

Github Actions Workflow looks as follow:

jobs:
  test_e2e:
    runs-on: self-hosted
    container:
      image: mcr.microsoft.com/playwright
      options: '--ipc=host --entrypoint /bin/bash'
    steps:
      - uses: actions/checkout@v2
      - run: npm ci --no-optional --no-audit --prefer-offline --progress=false
      - run: npm run ci:e2e

Output is:

 npm run ci:e2e
  shell: sh -e {0}

> @clap/clap-frontend@0.1.0 ci:e2e /__w/clap-ui/clap-ui
> jest -c jest-e2e.config.js

Protocol error (Browser.enable): Browser closed.
==================== Browser output: ====================
<launching> /ms-playwright/firefox-1250/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-8PNwPz -juggler-pipe -silent
<launched> pid=629
[pid=629][err] Running Nightly as root in a regular user's session is not supported.  ($HOME is /github/home which is owned by pwuser.)Error
    at /__w/clap-ui/clap-ui/node_modules/playwright/lib/server/firefox/ffConnection.js:55:63
    at new Promise (<anonymous>)
    at FFConnection.send (/__w/clap-ui/clap-ui/node_modules/playwright/lib/server/firefox/ffConnection.js:54:16)
    at Function.connect (/__w/clap-ui/clap-ui/node_modules/playwright/lib/server/firefox/ffBrowser.js:65:24)
    at Firefox._connectToTransport (/__w/clap-ui/clap-ui/node_modules/playwright/lib/server/firefox/firefox.js:65:38)
    at Firefox._innerLaunch (/__w/clap-ui/clap-ui/node_modules/playwright/lib/server/browserType.js:133:36)
    at async ProgressController.run (/__w/clap-ui/clap-ui/node_modules/playwright/lib/server/progress.js:76:28)
    at async Firefox.launch (/__w/clap-ui/clap-ui/node_modules/playwright/lib/server/browserType.js:78:25)
    at async BrowserServerLauncherImpl.launchServer (/__w/clap-ui/clap-ui/node_modules/playwright/lib/browserServerImpl.js:35:25)
    at async PlaywrightRunner.launchServer (/__w/clap-ui/clap-ui/node_modules/jest-playwright-preset/lib/PlaywrightRunner.js:68:44)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @clap/clap-frontend@0.1.0 ci:e2e: `jest -c jest-e2e.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @clap/clap-frontend@0.1.0 ci:e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /github/home/.npm/_logs/2021-05-11T12_50_21_530Z-debug.log
Error: Process completed with exit code 1.

Activity

  1. JoelEinbinder commented on May 11, 2021

    @JoelEinbinder
    Contributor

    Andrey Lushnikov (@aslushnikov) for help with docker.

    The code in firefox is in toolkit/xre/nsAppRunner.cpp, and it checks if the directories $HOME, $XDG_RUNTIME_DIR and $XAUTHORITY are owned by the current user. Could you try running with HOME=/root npm run ci:e2e?

  2. Th3S4mur41 commented on May 11, 2021

    @Th3S4mur41
    ContributorAuthor

    Thanks Joel Einbinder (@JoelEinbinder) that solved the issue 👍

  3. mxschmitt commented on May 21, 2021

    @mxschmitt
    Contributor

    Update: I raised an issue on GitHub side, since it seems not fixable on our side except using HOME=/root as a workaround as Joel has recommended.

  4. aslushnikov commented on Jun 15, 2021

    @aslushnikov
    Contributor

    Looks like the workaround is good-enough

  5. 24 remaining items

  6. taylorkline commented on Aug 3, 2023

    @taylorkline

    If possible, it'd be great if someone had a moment to update the docs at the following two locations:

  7. aslushnikov commented on Aug 3, 2023

    @aslushnikov
    Contributor

    Taylor Kline (@taylorkline) feel free to send us a pull request!

  8. nickofthyme commented on Apr 13, 2025

    @nickofthyme
    Contributor

    Update on this for future viewers...

    Instead of running the tests with HOME=/root npx playwright inside the container, you can just set the --user from the jobs.<job_id>.container.options as shown in the docs here, also shown below.

    name: Playwright Tests
    on:
      push:
        branches: [ main, master ]
      pull_request:
        branches: [ main, master ]
    jobs:
      playwright:
        name: 'Playwright Tests'
        runs-on: ubuntu-latest
        container:
          image: mcr.microsoft.com/playwright:v1.51.1-noble
          options: --user 1001 # <----- add this to change user from `root` to `pwuser` (aka `1001`)
        steps:
          - uses: actions/checkout@v4
          - uses: actions/setup-node@v4
            with:
              node-version: lts/*
          - name: Install dependencies
            run: npm ci
          - name: Run your tests
            run: npx playwright test
  9. SetupCoding commented on Apr 22, 2025

    @SetupCoding

    Update on this for future viewers...

    Instead of running the tests with HOME=/root npx playwright inside the container, you can just set the --user from the jobs.<job_id>.container.options as shown in the docs here, also shown below.

    name: Playwright Tests
    on:
    push:
    branches: [ main, master ]
    pull_request:
    branches: [ main, master ]
    jobs:
    playwright:
    name: 'Playwright Tests'
    runs-on: ubuntu-latest
    container:
    image: mcr.microsoft.com/playwright:v1.51.1-noble
    options: --user 1001 # <----- add this to change user from root to pwuser (aka 1001)
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-node@v4
    with:
    node-version: lts/*
    - name: Install dependencies
    run: npm ci
    - name: Run your tests
    run: npx playwright test

    In our CI we got the following error after adding the user param:

    Installing dependencies...
    Switching to root user to install dependencies...
    Password: su: Authentication failure
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

archivebrowser-firefox

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions