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

cypress shows error in Windows when passing args containing a url in 3.5.0 #5466

Closed
SimonZachrau opened this issue Oct 25, 2019 · 33 comments · Fixed by #5853 · May be fixed by ngChile/ngx-devkit-cypress-builder#20 or qsays/grafana#1
Closed
Assignees
Labels
browser: electron OS: windows type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0

Comments

@SimonZachrau
Copy link

Current behavior:

After updating to Cypress 3.5.0 I'm not able to open the Cypress GUI nor to run cypress run anymore. I'm using the Vue-Plugin "cli-plugin-e2e-cypress". I receiving the following error-message:

    Error: Command failed: C:\Users\localuser\Desktop\TEST\node_modules\cypress\bin\cypress run --config baseUrl=http://localhost:8082/
    at makeError (C:\Users\localuser\Desktop\TEST\node_modules\execa\index.js:174:9)
    at Promise.all.then.arr (C:\Users\localuser\Desktop\TEST\node_modules\execa\index.js:278:16)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Desired behavior:

I should be able to run my test with "cypress run" or open the GUI with "cypress open"

Steps to reproduce: (app code and test code)

  • upgrade from cypress 3.4.1 to 3.5.0
  • try "cypress run"

Versions

  • Cypress 3.5.0 (cli-plugin-e2e-cypress)
  • Windows 10
  • Chrome 77
@mheiss
Copy link

mheiss commented Oct 25, 2019

We also have this issue. Passing any arguments (--config baseUrl=https://localhost:56949) is not possible any more. Cypress will immediately terminate.

@mduft
Copy link

mduft commented Oct 25, 2019

I tested and on Linux it works. It seems that cypress.cmd is broken.
On Windows cypress.cmd open without any argument works fine, as soon as a command line argument is present, it immediately exits (exit code 0).

@krokofant
Copy link

As a workaround you can use environment variables to set the cypress configs. https://docs.cypress.io/guides/guides/environment-variables.html#Option-4-env

@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Oct 28, 2019
@jennifer-shehane
Copy link
Member

Are you all using the cli-plugin-e2e-cypress from Vue? Please we need to know exactly. We have lots of tests around Windows, passing env vars in this way, so we need to narrow the issue down to begin investigating.

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Oct 28, 2019

Can you also confirm what arguments you are seeing, I know someone say 'any arguments', but all of the examples have config, can you confirm the exact arguments that make it fail, thank you.

The reason I ask is because the cli-plugin-e2e-cypress plugin specifically handles the config argument, and more specifically the baseURL argument passed to that. This may be a bug in their plugin. https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-e2e-cypress/index.js#L31

@elinato
Copy link

elinato commented Oct 28, 2019

I'm using it on a react project: npx cypress run --env BASE_URL=https://****.azurewebsites.net

It works with Cypress 3.4.1 but not with 3.5. it doesnt show any error message just terminate

I use it on Windows

@pfoedermayr
Copy link

pfoedermayr commented Oct 28, 2019

@jennifer-shehane
We are not using the cli-plugin-e2e-cypress, "just" cypress w/ webpack-preprocessor (for TypeScript support).
It terminates immediately when providing the --config switch. When starting cypress w/o the config-switch it runs normally. (except the fact that base-url is not set correctly)

Example of how we are using cypress:

cypress open/run --project <subfolder> --config baseUrl=<baseUrl> --env user=<user>,password=<password>

@jennifer-shehane jennifer-shehane changed the title Cypress 3.5.0 - Cypress-GUI does not open and cypress run shows error-message Cypress 3.5.0 - cypress open and cypress run shows error in Windows when passing --config arg Oct 28, 2019
@jennifer-shehane jennifer-shehane changed the title Cypress 3.5.0 - cypress open and cypress run shows error in Windows when passing --config arg cypress open and cypress run shows error in Windows when passing --config arg in 3.5.0 Oct 28, 2019
@mduft
Copy link

mduft commented Oct 28, 2019

We're using it plain installed via npm from command line and Gradle. When passing either --config or --env or both it immediately exits (only on Windows).

@jennifer-shehane
Copy link
Member

Hey everyone,

Could you run Cypress in debug mode mode and print the entire set of logs here? Please include the error you are seeing also.

@pfoedermayr
Copy link

pfoedermayr commented Oct 29, 2019

Output from running cypress with set DEBUG=cypress:*:

yarn run v1.19.0
$ set DEBUG=cypress:* && cypress open --project ./integration --config baseUrl=http://localhost:23814 --env user=******,password=******
  cypress:cli cli starts with arguments ["C:\\Program Files\\nodejs\\node.exe","C:\\Repository\\node_modules\\cypress\\bin\\cypress","open","--project","./integration","--config","baseUrl=http://localhost:23814","--env","user=******,password=******"] +0ms
  cypress:cli NODE_OPTIONS is not set +0ms
  cypress:cli program parsing arguments +4ms
  cypress:cli opening Cypress +1ms
  cypress:cli parsed cli options { project: './integration',
  env: 'user=******,password=******',
  config: 'baseUrl=http://localhost:23814' } +133ms
  cypress:cli opening from options {"project":"./integration","env":"user=******,password=******","config":"baseUrl=http://localhost:23814"} +0ms
  cypress:cli command line arguments ["--env","user=******,password=******","--config","baseUrl=http://localhost:23814","--project","./integration"] +1ms
  cypress:cli verifying Cypress app +0ms
  cypress:cli checking environment variables +31ms
  cypress:cli checking if executable exists C:\Users\pf\AppData\Local\Cypress\Cache\3.5.0\Cypress\Cypress.exe +4ms
  cypress:cli Binary is executable? : true +6ms
  cypress:cli binaryDir is  C:\Users\pf\AppData\Local\Cypress\Cache\3.5.0\Cypress +33ms
  cypress:cli Reading binary package.json from: C:\Users\pf\AppData\Local\Cypress\Cache\3.5.0\Cypress\resources\app\package.json +0ms
  cypress:cli Found binary version 3.5.0 installed in: C:\Users\pf\AppData\Local\Cypress\Cache\3.5.0\Cypress +6ms
  cypress:cli { verified: true } +6ms
  cypress:cli is Verified ? true +3ms
  cypress:cli needs to start own Xvfb? false +0ms
  cypress:cli spawning, should retry on display problem? false +28ms
  cypress:cli spawning Cypress with executable: C:\Users\pf\AppData\Local\Cypress\Cache\3.5.0\Cypress\Cypress.exe +7ms
  cypress:cli spawn args [ '--env', 'user=******,password=******', '--config', 'baseUrl=http://localhost:23814', '--project', './integration', '--cwd', 'C:\\Repository' ] { detached: false, stdio: 'inherit', windowsHide: false } +31ms
  cypress:cli child event fired { event: 'exit', code: 4294967295, signal: null } +2s
  cypress:cli child event fired { event: 'close', code: 4294967295, signal: null } +3ms
Done in 2.91s.

@elinato
Copy link

elinato commented Oct 29, 2019

Output from running cypress with set DEBUG=cypress:*:

F:\Project\hub>npx cypress run --env BASE_URL=https://****.azurewebsites.net
  cypress:cli cli starts with arguments ["C:\\Program Files\\nodejs\\node.exe","F:\\Project\\hub\\node_modules\\cypress\\bin\\cypress","run","--env","BASE_URL=https://****.azurewebsites.net"] +0ms
  cypress:cli NODE_OPTIONS is not set +0ms
  cypress:cli program parsing arguments +2ms
  cypress:cli running Cypress +1ms
  cypress:cli parsed cli options { env: 'BASE_URL=https://****.azurewebsites.net' } +56ms
  cypress:cli verifying Cypress app +0ms
  cypress:cli checking environment variables +0ms
  cypress:cli checking if executable exists C:\Users\****\AppData\Local\Cypress\Cache\3.5.0\Cypress\Cypress.exe +2ms  cypress:cli Binary is executable? : true +1ms
  cypress:cli binaryDir is  C:\Users\****\AppData\Local\Cypress\Cache\3.5.0\Cypress +0ms
  cypress:cli Reading binary package.json from: C:\Users\****\AppData\Local\Cypress\Cache\3.5.0\Cypress\resources\app\package.json +0ms
  cypress:cli Found binary version 3.5.0 installed in: C:\Users\****\AppData\Local\Cypress\Cache\3.5.0\Cypress +2ms
  cypress:cli { verified: true } +2ms
  cypress:cli is Verified ? true +1ms
  cypress:cli processing run options +0ms
  cypress:cli --key is not set, looking up environment variable CYPRESS_RECORD_KEY +1ms
  cypress:cli run to spawn.start args ["--run-project","F:\\Project\\hub","--env","BASE_URL=https://****.azurewebsites.net"] +0ms
  cypress:cli needs to start own Xvfb? false +0ms
  cypress:cli spawning, should retry on display problem? false +0ms
  cypress:cli spawning Cypress with executable: C:\Users\****\AppData\Local\Cypress\Cache\3.5.0\Cypress\Cypress.exe +7ms
  cypress:cli spawn args [ '--run-project', 'F:\\Project\\hub', '--env', 'BASE_URL=https://****.azurewebsites.net', '--cwd', 'F:\\Project\\hub' ] { detached: false, stdio: 'pipe', windowsHide: false } +1ms
  cypress:cli piping process STDIN into child STDIN +8ms
  cypress:cli piping child STDOUT to process STDOUT +0ms
  cypress:cli piping child STDERR to process STDERR +1ms
  cypress:cli child event fired { event: 'exit', code: 4294967295, signal: null } +16ms
  cypress:cli child event fired { event: 'close', code: 4294967295, signal: null } +1ms

@PetMou
Copy link

PetMou commented Oct 29, 2019

Same problem here. As a workaround I could use --config-file parameter.

@kristofferlindvall
Copy link

I have the same problem too on both 3.5 and 3.6 versions.

@jennifer-shehane jennifer-shehane changed the title cypress open and cypress run shows error in Windows when passing --config arg in 3.5.0 cypress open and cypress run shows error in Windows when passing --config arg with baseUrl in 3.5.0 Nov 5, 2019
@jennifer-shehane
Copy link
Member

I think this may be occurring due to a change in Electron (which we upgraded) where they strip arguments after an argument containing a url. Seems localized to Windows though. electron/electron#13039

  1. Can everyone confirm/deny if the arguments being passed during the error contain a url somewhere in the arguments list and that removing this url solves the issue?
  2. Also if this is true, this should not be happening in Chrome, so potentially passing --browser chrome to an installed Chrome browser would fix this issue.

@jennifer-shehane jennifer-shehane added type: regression A bug that didn't appear until a specific Cy version release browser: electron labels Nov 5, 2019
@jennifer-shehane jennifer-shehane changed the title cypress open and cypress run shows error in Windows when passing --config arg with baseUrl in 3.5.0 cypress shows error in Windows when passing args containing a url in 3.5.0 Nov 5, 2019
@pfoedermayr
Copy link

  1. Can everyone confirm/deny if the arguments being passed during the error contain a url somewhere in the arguments list and that removing this url solves the issue?

Moving thebaseUrl from the arguments into the config-file solves it.

  1. Also if this is true, this should not be happening in Chrome, so potentially passing --browser chrome to an installed Chrome browser would fix this issue.

Passing --browser chrome does not help. Debug output below:

yarn run v1.19.0
$ set DEBUG=cypress:* && cypress run --project ./integration --config baseUrl=http://localhost:23814 --env user=******,password=****** --browser chrome
  cypress:cli cli starts with arguments ["C:\\Program Files\\nodejs\\node.exe","C:\\Repository\\node_modules\\cypress\\bin\\cypress","run","--project","./integration","--config","baseUrl=http://localhost:23814","--env","user=******,password=******","--browser","chrome"] +0ms
  cypress:cli NODE_OPTIONS is not set +0ms
  cypress:cli program parsing arguments +26ms
  cypress:cli running Cypress +2ms
  cypress:cli parsed cli options { project: './integration',
  env: 'user=******,password=******',
  config: 'baseUrl=http://localhost:23814',
  browser: 'chrome' } +115ms
  cypress:cli verifying Cypress app +0ms
  cypress:cli checking environment variables +20ms
  cypress:cli checking if executable exists C:\Users\pf\AppData\Local\Cypress\Cache\3.5.0\Cypress\Cypress.exe +3ms
  cypress:cli Binary is executable? : true +2ms
  cypress:cli binaryDir is  C:\Users\pf\AppData\Local\Cypress\Cache\3.5.0\Cypress +1ms
  cypress:cli Reading binary package.json from: C:\Users\pf\AppData\Local\Cypress\Cache\3.5.0\Cypress\resources\app\package.json +0ms
  cypress:cli Found binary version 3.5.0 installed in: C:\Users\pf\AppData\Local\Cypress\Cache\3.5.0\Cypress +23ms
  cypress:cli { verified: true } +24ms
  cypress:cli is Verified ? true +3ms
  cypress:cli processing run options +0ms
  cypress:cli --key is not set, looking up environment variable CYPRESS_RECORD_KEY +1ms
  cypress:cli run to spawn.start args ["--run-project","./integration","--env","user=******,password=******","--config","baseUrl=http://localhost:23814","--browser","chrome"] +0ms      
  cypress:cli needs to start own Xvfb? false +0ms
  cypress:cli spawning, should retry on display problem? false +1ms
  cypress:cli spawning Cypress with executable: C:\Users\pf\AppData\Local\Cypress\Cache\3.5.0\Cypress\Cypress.exe +4ms
  cypress:cli spawn args [ '--run-project', './integration', '--env', 'user=******,password=******', '--config', 'baseUrl=http://localhost:23814', '--browser', 'chrome', '--cwd', 'C:\\Repository' ] { detached: false, stdio: 'pipe', windowsHide: false } +0ms
  cypress:cli piping process STDIN into child STDIN +33ms
  cypress:cli piping child STDOUT to process STDOUT +1ms
  cypress:cli piping child STDERR to process STDERR +0ms
  cypress:cli child event fired { event: 'exit', code: 4294967295, signal: null } +859ms
  cypress:cli child event fired { event: 'close', code: 4294967295, signal: null } +1ms

@dwelle
Copy link

dwelle commented Nov 6, 2019

That Electron PR allows for urls when the args are prefaced with extra --, e.g.:

npx cypress open -- --config baseUrl=https://google.com

Sadly, Cypress doesn't parse arguments in this format. I'm not sure how args in this format are passed to the Electron app, but it may be the only fix Cypress could do downstream.

EDIT: in fact, looking at DEBUG, I think all that cypress needs to do is prepend -- when spawning the process.

@badders
Copy link

badders commented Nov 7, 2019

Can confirm its windows only, exactly the same setup works just fine in linux, but fails with this issue on windows

@deniseruck
Copy link

@jennifer-shehane can we please get an update as to when this will be fixed

@bjowes
Copy link
Contributor

bjowes commented Nov 22, 2019

Another workaround is to launch cypress from the node module API. You pass the config as a js object and this still works fine on Windows.

@vesamet
Copy link

vesamet commented Nov 27, 2019

Same issue with vue-service-cli command test:e2e. It runs the following commands cypress run --config baseUrl=http://localhost:8080/kp/ and as other found, the --config parameter is the cause.

@ZwapKillrath
Copy link

Same here. Issue arose when upgrading from 3.4.1 to 3.5.0/3.6.1/3.7.0. Both with test runner and headless mode. See #5843 and #5710

@bahmutov bahmutov self-assigned this Dec 2, 2019
@bahmutov
Copy link
Contributor

bahmutov commented Dec 2, 2019

Confirming v3.7.0 on Windows is crashing

  cypress:cli spawning Cypress with executable: C:\Users\Administrator\AppData\Local\Cypress\Cache\3.7.0\Cypress\Cypress.exe +0ms
  cypress:cli spawn args [ '--run-project', 'c:\\Users\\Administrator\\test-crash-5466', '--config', 'baseUrl=http://foo', '--cwd', 'c:\\Users\\Administrator\\test-crash-5466' ] { detached: false, stdio: 'pipe', windowsHide: false } +0ms
  cypress:cli piping process STDIN into child STDIN +172ms
  cypress:cli piping child STDOUT to process STDOUT +0ms
  cypress:cli piping child STDERR to process STDERR +0ms
  cypress:cli child event fired { event: 'exit', code: 4294967295, signal: null } +31ms
  cypress:cli child event fired { event: 'close', code: 4294967295, signal: null } +0ms

Even passing an url inside --env crashes the child process.

Working: npx cypress run --env foo=http//foo
Not working:

Hmm, when I comment out --cwd argument and options object to child_process.spawn it is working

  cypress:cli spawn args [ '--run-project', 'c:\\Users\\Administrator\\test-crash-5466', '--env', 'foo=http://foo' ] { detached: false, stdio: 'inherit', windowsHide: false } +0ms
  cypress:cli piping process STDIN into child STDIN +188ms
  cypress:cli piping child STDOUT to process STDOUT +0ms
  cypress:cli piping child STDERR to process STDERR +0ms

2019-12-02T22:12:44.261Z cypress:server:cypress starting cypress with argv [ 'C:\\Users\\Administrator\\AppData\\Local\\Cypress\\Cache\\3.7.0\\Cypress\\Cypress.exe', '--run-project', 'c:\\Users\\Administrator\\test-crash-5466', '--env', 'foo=http://foo' ]
2019-12-02T22:12:44.877Z cypress:server:cypress starting in mode run
It looks like you are running the Cypress binary directly.

This is not the recommended approach, and Cypress may not work correctly.

Please install the 'cypress' NPM package and follow the instructions here:

https://on.cypress.io/installing-cypress
2019-12-02T22:12:44.880Z cypress:server:cypress running Electron currently

Interesting - it seems by adding "dummy" '--' to the arguments when spawning the child process I can make the Electron work - just like this comment suggests #5466 (comment)

 cypress:cli spawn args [ '--run-project', 'c:\\Users\\Administrator\\test-crash-5466', '--', '--env', 'foo=http://foo', '--bar' ] { detached: false, stdio: 'inherit', windowsHide: false } +0ms
  cypress:cli piping process STDIN into child STDIN +172ms
  cypress:cli piping child STDOUT to process STDOUT +16ms
  cypress:cli piping child STDERR to process STDERR +0ms

2019-12-02T22:21:17.350Z cypress:server:cypress starting cypress with argv [ 'C:\\Users\\Administrator\\AppData\\Local\\Cypress\\Cache\\3.7.0\\Cypress\\Cypress.exe', '--run-project', 'c:\\Users\\Administrator\\test-crash-5466', '--', '--env', 'foo=http://foo', '--bar' ]
2019-12-02T22:21:17.985Z cypress:server:cypress starting in mode run

@bahmutov
Copy link
Contributor

bahmutov commented Dec 2, 2019

Added a failing test to test project https://github.com/cypress-io/cypress-example-todomvc/tree/3.7.1 - and updated AppVeyor to confirm it fails

Screen Shot 2019-12-02 at 6 34 31 PM

@dwelle
Copy link

dwelle commented Dec 3, 2019

@bahmutov no need to reverse-engineer/guess what's going on. It's a known feature of new Electron versions, as @jennifer-shehane linked.

electron/electron#13039 (fixing electron/electron#13226 (comment))

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 4, 2019

The code for this is done in cypress-io/cypress#5853, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Dec 4, 2019
@albernhagen
Copy link

Thanks for getting this fixed! Do we know approximately when this will be released?

@albernhagen
Copy link

albernhagen commented Dec 12, 2019

Any chance this will release this week? I have some E2E test pipelines in our deploy process that I'd love to get updated waiting on this fix. If there's anything I can do to help, I'd be happy to.

@ZwapKillrath
Copy link

Any chance this will release this week? I have some E2E test pipelines in our deploy process that I'd love to get updated waiting on this fix. If there's anything I can do to help, I'd be happy to.

Oh, yes. It would be nice. We desperately need this fix asap. Impossible for us to upgrade from 3.4.1 to newer versions with this bug. Have been trying for weeks.

@Abelhawk
Copy link

Abelhawk commented Dec 12, 2019

Yep, we've got a project blocked only by this issue as well. Any information as to when this will be fixed would be appreciated.

@deniseruck
Copy link

We also are unable to upgrade from 3.4.1

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 12, 2019

Released in 3.8.0.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.