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

Docker - Browser: 'chrome' was not found on your system or is not supported by Cypress #8611

Closed
sabarishnarain opened this issue Sep 18, 2020 · 32 comments
Assignees
Labels
pkg/launcher This is due to an issue in the packages/launcher directory type: bug

Comments

@sabarishnarain
Copy link

sabarishnarain commented Sep 18, 2020

cypress version 4.11

Current behavior:

cypress run --browser chrome --headless --spec "**/pr/*.spec.ts"",

Tests intermittently fails with the following.

Browser: 'chrome' was not found on your system or is not supported by Cypress - on docker

This happens more frequently in azure CI services on using cypress/browsers:node12.16.2-chrome81-ff75.
Workaround is to re-try the job several times.

cypress.log

Desired behavior:

Tests should run on chrome.

Test code to reproduce

Not sure how to provide a test code. This problem is very common with the above docker image and in Azure CI. I can provide the link to the CI job if needed.

@gustawx
Copy link

gustawx commented Sep 22, 2020

Today I had exactly same issue with version 5.2.0:
image

I run tests in a docker image. This happened for the first time and when I ran tests again all was fine

I use GitLab CI

@gustawx
Copy link

gustawx commented Sep 23, 2020

@sabarishnarain it seems to work fine with version 5.1.0

@johrues
Copy link

johrues commented Nov 19, 2020

@gustawx and which docker image are you using? i had the issue reproducible even with 5.1.0 version

@gustawx
Copy link

gustawx commented Nov 19, 2020

Currently I'm successful with latest version 5.6.0.
If you have the problem with 5.1.0 the problem might be more complex and occur under some specific circumstances. Did you try latest version?

@johrues
Copy link

johrues commented Nov 19, 2020

yep, im using latests cypress/browsers:node12.18.3-chrome83-ff77 and latest cypress version 5.6.0

$ npx cypress run --record --key  --config baseUrl="https://www.notino.$COUNTRY" --env _countryCode=$COUNTRY --browser $BROWSER --headless --group $COUNTRY-$BROWSER-Run --ci-build-id $CI_PIPELINE_ID
[08:02:34]  Verifying Cypress can run /root/.cache/Cypress/5.6.0/Cypress [started]
[08:02:53]  Verifying Cypress can run /root/.cache/Cypress/5.6.0/Cypress [completed]
Can't run because you've entered an invalid browser name.
Browser: 'chrome' was not found on your system or is not supported by Cypress.
Cypress supports the following browsers:
- chrome
- chromium
- edge
- electron
- firefox
You can also use a custom browser: https://on.cypress.io/customize-browsers
Available browsers found on your system are:
- firefox
- electron

edit: im using this to run ~24 runs for 24 country permutations of our web and approx. every 3rd run one of the 24 jobs fails with the above message

@j2020v
Copy link

j2020v commented Nov 25, 2020

What's on your dockerfile?

@johrues
Copy link

johrues commented Nov 25, 2020

@j2020v I was using the default image cypress/browsers:node12.18.3-chrome83-ff77 one thing I tried doing was to rehost this on our GitLab so just
FROM cypress/browsers:node12.18.3-chrome83-ff77

recently I tried updating to the newest image cypress/browsers:node14.15.0-chrome86-ff82 and cypress 6.0.0 and still running into the same issue

The worst thing is more time I spent debugging this more nonsensical it seems

Google Chrome 86.0.4240.193 
$ npx cypress info
Displaying Cypress info...
Detected 2 browsers installed:
1. Chrome
  - Name: chrome
  - Channel: stable
  - Version: 86.0.4240.193
  - Executable: google-chrome
2. Firefox
  - Name: firefox
  - Channel: stable
  - Version: 82.0.3
  - Executable: firefox
Note: to run these browsers, pass <name>:<channel> to the '--browser' field
Examples:
- cypress run --browser chrome
- cypress run --browser firefox
Learn More: https://on.cypress.io/launching-browsers
Proxy Settings: none detected
Environment Variables: none detected
Application Data: /root/.config/cypress/cy/development
Browser Profiles: /root/.config/cypress/cy/development/browsers
Binary Caches: /root/.cache/Cypress
Cypress Version: 6.0.0
System Platform: linux (Debian - 10.6)
System Memory: 63.2 GB free 33 GB
$ npx cypress run --record --key <my-key> --config baseUrl="https://www.notino.$COUNTRY" --env _countryCode=$COUNTRY --browser $BROWSER --headless --group $COUNTRY-$BROWSER-Run --ci-build-id $CI_PIPELINE_ID
[08:56:20]  Verifying Cypress can run /root/.cache/Cypress/6.0.0/Cypress [started]
[08:56:23]  Verifying Cypress can run /root/.cache/Cypress/6.0.0/Cypress [completed]
Can't run because you've entered an invalid browser name.
Browser: 'chrome' was not found on your system or is not supported by Cypress.
Cypress supports the following browsers:
- chrome
- chromium
- edge
- electron
- firefox
You can also use a custom browser: https://on.cypress.io/customize-browsers
Available browsers found on your system are:
- firefox
- electron

@johrues
Copy link

johrues commented Nov 25, 2020

here is also pastebin with debug enabled https://pastebin.com/TfDr5rYE

@denis-domanskii
Copy link

I just faced the same issue:

   Browser: 'chrome' was not found on your system or is not supported by Cypress.
   Cypress supports the following browsers:
   - chrome
   - chromium
   - edge
   - electron
   - firefox (Cypress support in beta)
   You can also use a custom browser: https://on.cypress.io/customize-browsers 
   Available browsers found on your system are:
   - firefox
   - electron

Cypress 5.2.0
Docker image: cypress/browsers:node12.19.0-chrome86-ff82

It looks like flickering issue, because previous and next builds with the same configuration executed without the issue.

@denis-domanskii
Copy link

Also I see a similar issue here: #8736

@johrues
Copy link

johrues commented Jan 6, 2021

any news about this? this is still a problem for us

@madhav580
Copy link

Cypress looks for chrome installation in this Path: "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe". If chrome installed in "C:/Program Files/" then it will throw an error.

@Undistraction
Copy link

Undistraction commented Jan 12, 2021

Intermittent issue on our CI with [email protected] using Cypress official Docker image.

Same error, approx 1/50th of the time. Restarting the job almost always results in a successful run. No clear pattern.

@kaiyoma
Copy link

kaiyoma commented Jan 25, 2021

Same here. Problem happens randomly, maybe 1-2% of the time, even though nothing about our infra is changing. Also running Cypress 6.2.1.

@Undistraction
Copy link

We've been closely monitoring this issue. Same image for all our runners. Same resources for all our runners. But we are seeing two Cypress-related errors intermittently. This one and Smoke test timeouts.

@pastelsky
Copy link

pastelsky commented Feb 9, 2021

We noticed this issue happening too in one of our longer (~50 lines) cypress tests (rare, but annoying), but another hello world test on google.com has had no such failure on any run in the last 30 days.

Could it depend on the nature of the test?

@macrozone
Copy link

macrozone commented Mar 15, 2021

this happens for me as well when it try to run the tests with --record --parallel

using cypress/browsers:node12.18.3-chrome89-ff86

seems to work now using cypress/browsers:node14.16.0-chrome89-ff86

@aninhalacerda
Copy link

it only worked when I've tried with cypress/included:6.3.0 and Cypress version 6.8.0

@MicmladenTo
Copy link

MicmladenTo commented Mar 29, 2021

Cypress looks for chrome installation in this Path: "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe". If chrome installed in "C:/Program Files/" then it will throw an error.

What @madhav580 here said is what appears to have been the issue for a good deal of these cases, it seems.

@kaiyoma
Copy link

kaiyoma commented Mar 29, 2021

I see this with Chrome installed on Debian 9.

@guyguy333
Copy link

Having the same issue with node14.7.0-chrome84 docker image.

@pgfisico
Copy link

I believe this is an issue with the Cypress launcher and not Docker image related. The issue is caused by not fully reading the output of the browser's version command. In the cypress:launcher logs you will see Could not extract version from stdout using regex: { stdout: '', versionRegex: <varies depending on browser> }. Note that stdout is empty and this log message is different from what you see when the binary is not found (which results in ENOENT for example).

The issue is in getOutput()

getOutput: (cmd: string, args: string[]): Bluebird<{ stdout: string, stderr?: string }> => {
if (process.platform === 'win32') {
// execa has better support for windows spawning conventions
throw new Error('getOutput should not be used on Windows - use execa instead')
}
return new Bluebird((resolve, reject) => {
let stdout = ''
let stderr = ''
const proc = cp.spawn(cmd, args)
const finish = () => {
proc.kill()
resolve({ stderr, stdout })
}
proc.on('exit', finish)
proc.stdout.on('data', (chunk) => {
stdout += chunk
})
proc.stderr.on('data', (chunk) => {
stderr += chunk
})
proc.on('error', (err) => {
proc.kill()
reject(err)
})
})
},

When the exit event occurs it is not guaranteed that the stdio streams are closed.

According to the PR that introduced getOutput() (#7039)

mysteriously, execa would hang on --version when used with the snap

To resolve the issue, Cypress could revert to using the execa package (assuming no breakage as mentioned in the PR) or update getOutput() to ensure it fully reads the output.


As an example, for Chrome Cypress tries all of google-chrome, chrome, and google-chrome-stable by default.

{
name: 'chrome',
family: 'chromium',
channel: 'stable',
displayName: 'Chrome',
versionRegex: /Google Chrome (\S+)/m,
binary: ['google-chrome', 'chrome', 'google-chrome-stable'],
},

In the Cypress Docker images, only google-chrome and google-chrome-stable can be used to run Chrome; chrome does not work. This gives Cypress two tries to detect the browser. If running one binary fails to detect the browser because Cypress did not fully read the output, the opposite binary could still work. If the output is not read completely for both binaries then Cypress will conclude that Chrome is not installed. The issue is intermittent due to the timing related nature of the issue (sometimes stdout will have been fully read when the exit event occurs but sometimes it hasn't) and that Cypress may have to encounter the issue multiple times before detection of a single browser fails.

I have observed one of the two Chrome detections fail in the Docker container by running cypress info in an infinite loop.


I have observed the general issue when running Cypress intermittently with Cypress 6.x and Cypress 7.1.0.

You can see the issue with empty stdout in the provided logs

The earliest Cypress version I found this issue reported with is 4.12.0 (#9044). getOutput() was released in Cypress 4.4.1 (#7020 (comment))


Potential duplicate issues

Potential obsolete issues

@denis-domanskii
Copy link

@pgfisico it's a great investigation, thank you!

@bahmutov @jennifer-shehane probably you can fix it? Seems now the fix is clear.

@jennifer-shehane jennifer-shehane added pkg/launcher This is due to an issue in the packages/launcher directory type: bug stage: ready for work The issue is reproducible and in scope labels Apr 28, 2021
@bahmutov
Copy link
Contributor

bahmutov commented May 3, 2021

ughh, @pgfisico I ran Chrome detection 1000 times in a row in a Docker container, did not see the empty output. Do you know how one could see the STDOUT still streaming after the exit event? I would love to recreate this behavior before changing the getOutput() function

@jennifer-shehane
Copy link
Member

We've merged a PR so that the verify process listens for the 'close' event instead of 'exit'. We're not sure if this solves this issue since we weren't able to recreate it.

You can install the pre-release with the potential fix by following the instructions here. Please let us know if this seems to fix the issue or not.

@cypress-bot cypress-bot bot added stage: to do and removed stage: needs investigating Someone from Cypress needs to look at this labels May 11, 2021
@jennifer-shehane
Copy link
Member

We released 7.3.0 with a change that we believe should fix this issue. This error should only display when Chrome is not installed on the system.

Please comment in this issue if this error is still displaying in your Docker container with Chrome installed after updating to 7.3.0.

@mahdiMustapha
Copy link

I had exactly same issue with version : 8.3.0 . any help please !

@AnnaKarinaNava
Copy link

Please help!

We are using cypress v7.6 and the situation is quite frequent for us still

@sabarishnarain
Copy link
Author

@AnnaKarinaNava The recommended workaround is to use the chrome/ff images and it appears it has worked out so far. I tried cypress/browsers:node12.18.3-chrome89-ff86 now and it works fine.

Thanks to the cypress team who appears to have addressed this issue. I'm not active over my personal projects now, but if anyone still sees this problem please feel free to re-open.

@kpturner
Copy link

@AnnaKarinaNava The recommended workaround is to use the chrome/ff images and it appears it has worked out so far. I tried cypress/browsers:node12.18.3-chrome89-ff86 now and it works fine.

Thanks to the cypress team who appears to have addressed this issue. I'm not active over my personal projects now, but if anyone still sees this problem please feel free to re-open.

If I may say so that is not a very good description of how one is supposed to work around the problem. I get this issue with 8.7.0 when using github-actions. Where does one specify cypress/browsers:node12.18.3-chrome89-ff86 ?

@derekcharles
Copy link

derekcharles commented Nov 30, 2021

Could a more up-to-date image containing the most up to date version of chrome-stable be released so that the workaround can be utilized? The application that I have automation built requires t the most recent version of chrome be used or else there is an error (This is for an internal application). I am getting the " Browser: 'chrome' was not found on your system or is not supported by Cypress." error using cypress/base:16.5.0 docker image. My Dockerfile handles retrieving the latest version of chrome-stable.

The most recent chrome/ff image is for chrome version 94 (chrome94-ff93). I require chrome-stable 96..

@joearinze
Copy link

tried image: cypress/browsers:node14.15.0-chrome86-ff82 and it works fine now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/launcher This is due to an issue in the packages/launcher directory type: bug
Projects
None yet
Development

No branches or pull requests