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

Firefox not found with root user and non-root $HOME #27121

Open
MikeMcC399 opened this issue Jun 23, 2023 · 4 comments
Open

Firefox not found with root user and non-root $HOME #27121

MikeMcC399 opened this issue Jun 23, 2023 · 4 comments
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: feature New feature that does not currently exist

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Jun 23, 2023

What would you like?

If an attempt is made to run Cypress against the Mozilla Firefox browser in a Cypress Docker container runner under GitHub Actions when the user is root Cypress should log the error message from Firefox:

"Running Firefox as root in a regular user's session is not supported. ($HOME is /github/home which is owned by uid 1001.)"

This is the error message which is produced when
firefox --version
is executed directly in a GitHub Actions workflow.

Cypress however outputs the message:

"Browser: firefox was not found on your system or is not supported by Cypress."

Why is this needed?

The message "firefox was not found on your system" is misleading. This message is output even though Firefox is installed.

The resolution necessary is to use the GitHub Actions
jobs.<job_id>.container.options with
--user 1001 to match the ownership of the $HOME directory.

Other

Repo https://github.com/MikeMcC399/cy-firefox-docker demonstrates this issue using

cypress/browsers:latest

See .github/workflows/firefox.yml

Debug logs

https://github.com/MikeMcC399/cy-firefox-docker/actions/workflows/firefox-debug.yml

image

@MikeMcC399 MikeMcC399 changed the title Better error message for Firefox in GitHub Actions with Cypress Docker Improve error message for Firefox in GitHub Actions with Cypress Docker as root Jun 24, 2023
@warrensplayer warrensplayer added type: feature New feature that does not currently exist E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. labels Jun 28, 2023
@warrensplayer
Copy link
Contributor

@MikeMcC399 Thanks as usual for all the hard work documenting issues and creating excellent reproductions. It always makes it so easy to see what is happening.

@warrensplayer warrensplayer removed their assignment Jul 5, 2023
@MikeMcC399 MikeMcC399 changed the title Improve error message for Firefox in GitHub Actions with Cypress Docker as root Firefox not found with root user and non-root $HOME Jun 6, 2024
@MikeMcC399
Copy link
Contributor Author

The Firefox detection issue by Cypress is reproducible without GitHub Actions in a local Docker container.

Cypress fails to find the Firefox browser if the user is root and the HOME environment variable is set to a directory owned by a non-root user. This is demonstrated below using the non-root user node.

Firefox reports:

Running Firefox as root in a regular user's session is not supported. ($HOME is /home/node which is owned by node.)

Cypress incorrectly reports:

Browser: firefox was not found on your system or is not supported by Cypress.

Steps to reproduce

Environment: Docker desktop v4.30.0

git clone https://github.com/cypress-io/cypress-docker-images
cd cypress-docker-images/factory/test-project
docker run -it --rm -v .:/e2e -w /e2e --entrypoint bash cypress/included
firefox --version
cypress info
export HOME=/home/node
firefox --version
cypress run --browser firefox

Logs

git clone https://github.com/cypress-io/cypress-docker-images
cd cypress-docker-images/factory/test-project
docker run -it --rm -v .:/e2e -w /e2e --entrypoint bash cypress/included

Success

User is root and $HOME is /root

root@0235712be24c:/e2e# firefox --version
Mozilla Firefox 126.0.1
root@0235712be24c:/e2e# cypress info

DevTools listening on ws://127.0.0.1:36975/devtools/browser/991ade34-dcf7-4886-b9cf-62e7de7600f6
Displaying Cypress info...

Detected 3 browsers installed:

1. Chrome
  - Name: chrome
  - Channel: stable
  - Version: 125.0.6422.141
  - Executable: google-chrome

2. Edge
  - Name: edge
  - Channel: stable
  - Version: 125.0.2535.85
  - Executable: edge

3. Firefox
  - Name: firefox
  - Channel: stable
  - Version: 126.0.1
  - Executable: firefox

Note: to run these browsers, pass <name>:<channel> to the '--browser' field

Examples:
- cypress run --browser firefox
- cypress run --browser chrome

Learn More: https://on.cypress.io/launching-browsers

Proxy Settings: none detected
Environment Variables:
CYPRESS_CACHE_FOLDER: /root/.cache/Cypress
CYPRESS_FACTORY_DEFAULT_NODE_VERSION: 20.14.0

Application Data: /root/.config/cypress/cy/development
Browser Profiles: /root/.config/cypress/cy/development/browsers
Binary Caches: /root/.cache/Cypress

Cypress Version: 13.11.0 (stable)
System Platform: linux (Debian - 12.5)
System Memory: 5.16 GB free 4.1 GB

Failure

User is still root and $HOME is /home/node with non-root ownership

root@0235712be24c:/e2e# export HOME=/home/node
root@0235712be24c:/e2e# firefox --version
Running Firefox as root in a regular user's session is not supported.  ($HOME is /home/node which is owned by node.)
root@0235712be24c:/e2e# cypress run --browser firefox


DevTools listening on ws://127.0.0.1:37881/devtools/browser/3c93fc63-e7b7-4a1f-899f-242fd9fc5903
Can't run because you've entered an invalid browser name.

Browser: firefox was not found on your system or is not supported by Cypress.

Cypress supports the following browsers:
 - electron
 - chrome
 - chromium
 - chrome:canary
 - edge
 - firefox

You can also use a custom browser: https://on.cypress.io/customize-browsers

Available browsers found on your system are:
 - chrome
 - edge
 - electron
Can't run because you've entered an invalid browser name.

Browser: firefox was not found on your system or is not supported by Cypress.

Cypress supports the following browsers:
 - electron
 - chrome
 - chromium
 - chrome:canary
 - edge
 - firefox

You can also use a custom browser: https://on.cypress.io/customize-browsers

Available browsers found on your system are:
 - chrome
 - edge
 - electron

@MikeMcC399
Copy link
Contributor Author

MikeMcC399 commented Jun 6, 2024

I originally submitted this as a feature request. Possibly it should be classed as a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: feature New feature that does not currently exist
Projects
None yet
Development

No branches or pull requests

2 participants