cypress: VSCode git pre-push hook triggers: bad option: --no-sandbox

Current behavior:

When pre-push hook trigger via VSCode build-in git extension, we have the following error:

2020-06-11T14:33:53.786Z cypress:cli:cli cli starts with arguments ["/Users/xx/.nvm/versions/node/v10.16.0/bin/node","/Users/xx/repos/xxx/node_modules/xxxx/node_modules/.bin/cypress","run","--headless","--browser","chrome"]
2020-06-11T14:33:53.787Z cypress:cli NODE_OPTIONS is not set
2020-06-11T14:33:53.788Z cypress:cli:cli program parsing arguments
2020-06-11T14:33:53.793Z cypress:cli:cli running Cypress with args [ Command { commands: [], options: [ [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option] ], _execs: Set {}, _allowUnknownOption: false, _args: [], _name: 'run', _optionValues: {}, _storeOptionsAsProperties: true, _passCommandToAction: true, _actionResults: [], _helpFlags: '-h, --help', _helpDescription: 'output usage information', _helpShortFlag: '-h', _helpLongFlag: '--help', _noHelp: false, _exitCallback: undefined, _executableFile: undefined, parent: Command { commands: [Array], options: [Array], _execs: Set {}, _allowUnknownOption: false, _args: [], _name: 'cypress', _optionValues: {}, _storeOptionsAsProperties: true, _passCommandToAction: true, _actionResults: [], _helpFlags: '-h, --help', _helpDescription: 'output usage information', _helpShortFlag: '-h', _helpLongFlag: '--help', _usage: '<command> [options]', _events: [Object], _eventsCount: 9, rawArgs: [Array], args: [] }, _usage: '[options]', _description: 'Runs Cypress tests from the CLI without the GUI', _argsDescription: undefined, _events: [Object: null prototype] { 'option:browser': [Function], 'option:ci-build-id': [Function], 'option:config': [Function], 'option:config-file': [Function], 'option:env': [Function], 'option:group': [Function], 'option:key': [Function], 'option:headed': [Function], 'option:headless': [Function], 'option:no-exit': [Function], 'option:parallel': [Function], 'option:port': [Function], 'option:project': [Function], 'option:record': [Function], 'option:reporter': [Function], 'option:reporter-options': [Function], 'option:spec': [Function], 'option:tag': [Function], 'option:dev': [Function] }, _eventsCount: 19, exit: true, headless: true, browser: 'chrome' } ]
2020-06-11T14:33:53.961Z cypress:cli:cli variable-length opts parsed { args: [ '/Users/xx/.nvm/versions/node/v10.16.0/bin/node', '/Users/xx/repos/xxx/node_modules/xxxx/node_modules/.bin/cypress', 'run', '--headless', '--browser', 'chrome' ], opts: Command { commands: [], options: [ [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option], [Option] ], _execs: Set {}, _allowUnknownOption: false, _args: [], _name: 'run', _optionValues: {}, _storeOptionsAsProperties: true, _passCommandToAction: true, _actionResults: [], _helpFlags: '-h, --help', _helpDescription: 'output usage information', _helpShortFlag: '-h', _helpLongFlag: '--help', _noHelp: false, _exitCallback: undefined, _executableFile: undefined, parent: Command { commands: [Array], options: [Array], _execs: Set {}, _allowUnknownOption: false, _args: [], _name: 'cypress', _optionValues: {}, _storeOptionsAsProperties: true, _passCommandToAction: true, _actionResults: [], _helpFlags: '-h, --help', _helpDescription: 'output usage information', _helpShortFlag: '-h', _helpLongFlag: '--help', _usage: '<command> [options]', _events: [Object], _eventsCount: 9, rawArgs: [Array], args: [] }, _usage: '[options]', _description: 'Runs Cypress tests from the CLI without the GUI', _argsDescription: undefined, _events: [Object: null prototype] { 'option:browser': [Function], 'option:ci-build-id': [Function], 'option:config': [Function], 'option:config-file': [Function], 'option:env': [Function], 'option:group': [Function], 'option:key': [Function], 'option:headed': [Function], 'option:headless': [Function], 'option:no-exit': [Function], 'option:parallel': [Function], 'option:port': [Function], 'option:project': [Function], 'option:record': [Function], 'option:reporter': [Function], 'option:reporter-options': [Function], 'option:spec': [Function], 'option:tag': [Function], 'option:dev': [Function] }, _eventsCount: 19, exit: true, headless: true, browser: 'chrome' } }
2020-06-11T14:33:53.962Z cypress:cli parsed cli options { browser: 'chrome', headless: true }
2020-06-11T14:33:53.963Z cypress:cli verifying Cypress app
2020-06-11T14:33:53.964Z cypress:cli checking environment variables
2020-06-11T14:33:53.968Z cypress:cli checking if executable exists /Users/xx/Library/Caches/Cypress/4.7.0/Cypress.app/Contents/MacOS/Cypress
2020-06-11T14:33:53.970Z cypress:cli Binary is executable? : true
2020-06-11T14:33:53.970Z cypress:cli binaryDir is  /Users/xx/Library/Caches/Cypress/4.7.0/Cypress.app
2020-06-11T14:33:53.971Z cypress:cli Reading binary package.json from: /Users/xx/Library/Caches/Cypress/4.7.0/Cypress.app/Contents/Resources/app/package.json
2020-06-11T14:33:53.974Z cypress:cli Found binary version 4.7.0 installed in: /Users/xx/Library/Caches/Cypress/4.7.0/Cypress.app
2020-06-11T14:33:53.975Z cypress:cli { verified: true }
2020-06-11T14:33:53.975Z cypress:cli is Verified ? true
2020-06-11T14:33:53.976Z cypress:cli:run processing run options { browser: 'chrome', headless: true, key: null, spec: null, reporter: null, reporterOptions: null, project: '/Users/xx/repos/xxx' }
2020-06-11T14:33:53.976Z cypress:cli:run --key is not set, looking up environment variable CYPRESS_RECORD_KEY
2020-06-11T14:33:53.976Z cypress:cli:run run to spawn.start args ["--run-project","/Users/xx/repos/xxx","--browser","chrome","--headed",false]
2020-06-11T14:33:53.976Z cypress:cli needs to start own Xvfb? false
2020-06-11T14:33:53.977Z cypress:cli spawning, should retry on display problem? false
2020-06-11T14:33:53.983Z cypress:cli spawning Cypress with executable: /Users/xx/Library/Caches/Cypress/4.7.0/Cypress.app/Contents/MacOS/Cypress
2020-06-11T14:33:53.984Z cypress:cli spawn args [ '--no-sandbox', '--', '--run-project', '/Users/xx/repos/xxx', '--browser', 'chrome', '--headed', false, '--cwd', '/Users/xx/repos/xxx' ] { detached: false, stdio: [ 'inherit', 'inherit', 'pipe' ] }
2020-06-11T14:33:53.988Z cypress:cli piping child STDERR to process STDERR
/Users/xx/Library/Caches/Cypress/4.7.0/Cypress.app/Contents/MacOS/Cypress: bad option: --no-sandbox
2020-06-11T14:33:57.094Z cypress:cli child event fired { event: 'exit', code: 9, signal: null }
2020-06-11T14:33:57.094Z cypress:cli child event fired { event: 'close', code: 9, signal: null }
npm ERR! code ELIFECYCLE

(I marked some folder name to be 'x’s intentionally)

Desired behavior:

It should run Cypress test as it was trigger by git cli.

Test code to reproduce

Versions

Cypress: 4.7.0 MacOs: 10.14.5 Node Version: 10.16.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 15 (4 by maintainers)

Most upvoted comments

I also have this issue in downshift. We have a cypress test run in the pre-commit hook. It happens when I commit from VSCode.

[test:cypress] /Users/savram/Library/Caches/Cypress/6.2.0/Cypress.app/Contents/MacOS/Cypress: bad option: --no-sandbox
[test:cypress] 
[test:cypress] INFO: Gracefully shutting down. Please wait...
[test:cypress] Error: Command failed with exit code 9: npm run cy:run
[test:cypress]     at makeError (/Users/savram/Documents/git-repos/downshift/node_modules/start-server-and-test/node_modules/execa/lib/error.js:56:11)
[test:cypress]     at handlePromise (/Users/savram/Documents/git-repos/downshift/node_modules/start-server-and-test/node_modules/execa/index.js:114:26)
[test:cypress]     at processTicksAndRejections (internal/process/task_queues.js:97:5) {
[test:cypress]   command: 'npm run cy:run',
[test:cypress]   exitCode: 9,
[test:cypress]   signal: undefined,
[test:cypress]   signalDescription: undefined,
[test:cypress]   stdout: undefined,
[test:cypress]   stderr: undefined,
[test:cypress]   failed: true,
[test:cypress]   timedOut: false,
[test:cypress]   isCanceled: false,
[test:cypress]   killed: false
[test:cypress] }
[test:cypress] npm run test:cypress --silent exited with code 1

Let me know if I can provide more info.

I have the same exact issue with the same error while using precommit hook. Any potential fix or reason why this might be happening?

Edit: this only happens while using the Git extension GUI that comes with VSCode to commit like someone mentioned. If I use the command line it works fine.