Open MikeMcC399 opened 1 year ago
@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.
I reviewed the logs from the Github actions in the sample repo from @MikeMcC399 and can see the different behaviors.
Here are several related issues/PRs:
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.
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
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
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
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
I originally submitted this as a feature request. Possibly it should be classed as a bug?
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