Open
Description
While trying to debug an issue w/ cypress verify
getting stuck occasionally (related #6082), I'm getting the following stdout message from running cypress verify
in debug mode (via DEBUG=cypress:* yarn cypress verify
)
"It looks like you are running the Cypress binary directly. This is not the recommended approach, and Cypress may not work correctly."
Is this is an expected output from the smoke-test?
Current behavior:
❯ DEBUG=cypress:* npx cypress@latest verify
cypress:cli installing Cypress from NPM +0ms
cypress:cli installing with options {} +0ms
cypress:cli version in package.json is 3.8.1 +1ms
cypress:cli Reading binary package.json from: /Users/*********/Library/Caches/Cypress/3.8.1/Cypress.app/Contents/Resources/app/package.json +0ms
cypress:cli no binary installed under cli version +4ms
cypress:cli checking local file /Users/*********/.npm/_npx/47203/lib/3.8.1 cwd /Users/*********/.npm/_npx/47203/lib/node_modules/cypress +0ms
cypress:cli preparing to download and unzip version 3.8.1 to path /Users/*********/Library/Caches/Cypress/3.8.1 +0ms
cypress:cli needed Cypress version: 3.8.1 +0ms
cypress:cli source url https://download.cypress.io/desktop/3.8.1?platform=darwin&arch=x64 +0ms
cypress:cli downloading cypress.zip to "/var/folders/ds/cwtxfpmd76z4r_g__8r94tbc0000gn/T/cypress.zip" +0ms
cypress:cli Downloading package { url:
'https://download.cypress.io/desktop/3.8.1?platform=darwin&arch=x64',
proxy: null,
downloadDestination:
'/var/folders/ds/cwtxfpmd76z4r_g__8r94tbc0000gn/T/cypress.zip' } +1ms
cypress:cli redirect version: 3.8.1 +341ms
cypress:cli expected checksum 64ba19b0fe70e5b4eda6dad53c16a8de0234a09871462c510f8e44e5226e5bf17bcbbb87051117aba114bca0f1e875be3ebe1331d4376e8c9f30dac9e11c3c5e +136ms
cypress:cli expected file size 167102535 +0ms
cypress:cli downloading finished +6s
cypress:cli verifying checksum and file size +1ms
cypress:cli downloaded file has the expected checksum and size ✅ +505ms
cypress:cli finished downloading file: /var/folders/ds/cwtxfpmd76z4r_g__8r94tbc0000gn/T/cypress.zip +7s
cypress:cli:unzip unzipping from /var/folders/ds/cwtxfpmd76z4r_g__8r94tbc0000gn/T/cypress.zip +0ms
cypress:cli:unzip into /Users/*********/Library/Caches/Cypress/3.8.1 +0ms
cypress:cli:unzip zipFile entries count 40147 +7ms
cypress:cli:unzip unzipping via `ditto` +0ms
cypress:cli:unzip unzip completed { yauzlMs: 7, unzipMs: 26116 } +26s
cypress:cli removing zip file /var/folders/ds/cwtxfpmd76z4r_g__8r94tbc0000gn/T/cypress.zip +26s
cypress:cli finished installation in /Users/*********/Library/Caches/Cypress/3.8.1 +17ms
cypress:cli:cli cli starts with arguments ["/usr/local/bin/node","/Users/*********/.npm/_npx/47203/bin/cypress","verify"] +0ms
cypress:cli NODE_OPTIONS is not set +0ms
cypress:cli:cli program parsing arguments +3ms
cypress:cli parsed cli options {} +3ms
cypress:cli verifying Cypress app +0ms
cypress:cli checking environment variables +1ms
cypress:cli checking if executable exists /Users/*********/Library/Caches/Cypress/3.8.1/Cypress.app/Contents/MacOS/Cypress +2ms
cypress:cli Binary is executable? : true +1ms
cypress:cli binaryDir is /Users/*********/Library/Caches/Cypress/3.8.1/Cypress.app +0ms
cypress:cli Reading binary package.json from: /Users/*********/Library/Caches/Cypress/3.8.1/Cypress.app/Contents/Resources/app/package.json +0ms
cypress:cli Found binary version 3.8.1 installed in: /Users/*********/Library/Caches/Cypress/3.8.1/Cypress.app +3ms
cypress:cli could not read binary_state.json file +3ms
cypress:cli {} +0ms
cypress:cli is Verified ? undefined +1ms
cypress:cli force verify +0ms
cypress:cli running binary verification check 3.8.1 +0ms
It looks like this is your first time using Cypress: 3.8.1
cypress:cli clearing out the verified version +3ms
cypress:cli needs Xvfb? false +0ms
cypress:cli spawning, should retry on display problem? false +1ms
cypress:cli disabling Electron sandbox +0ms
cypress:cli running smoke test +0ms
cypress:cli using Cypress executable /Users/*********/Library/Caches/Cypress/3.8.1/Cypress.app/Contents/MacOS/Cypress +0ms
cypress:cli smoke test command: /Users/*********/Library/Caches/Cypress/3.8.1/Cypress.app/Contents/MacOS/Cypress --no-sandbox --smoke-test --ping=965 +0ms
cypress:cli smoke test timeout 30000 ms +0ms
⠴ Verifying Cypress can run /Users/*********/Library/Caches/Cypress/3.8.1/Cypress.app
cypress:cli smoke test stdout "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
965" +2s
cypress:cli write verified: true +1ms
✔ Verified Cypress! /Users/*********/Library/Caches/Cypress/3.8.1/Cypress.app
Desired behavior:
I did a little digging myself & here what I've found:
- Cypress prints out the message above when
options.invokedFromCli === false
https://github.com/cypress-io/cypress/blob/v3.8.1/packages/server/lib/cypress.coffee#L59 - This
options.invokedFromCli
is computed based off theoptions.cwd
value https://github.com/cypress-io/cypress/blob/v3.8.1/packages/server/lib/util/args.js#L172 - This
options.cwd
is inherited from the--cwd
flag, which is injected here https://github.com/cypress-io/cypress/blob/v3.8.1/cli/lib/exec/spawn.js#L84
Based on the findings above, I "believe" this is what's happening under the hood:
- The cypress verify command runs the a smoke test via
runSmokeTest()
https://github.com/cypress-io/cypress/blob/v3.8.1/cli/lib/tasks/verify.js#L43 runSmokeTest()
starts the test by exec'ing the Cypress binary & spawns a child process https://github.com/cypress-io/cypress/blob/v3.8.1/cli/lib/tasks/verify.js#L113- Since the binary was exec'ed via the smoke test, the
--cwd flag
isn't injected - Hence the Cypress child-process (spawn'ed from cypress verify) determines that it wasn't being launched directly from the CLI & prints out the message
(From what I've seen so far, seems like this is the intended behaviour & it's harmless since the verify task succeeded.)
Steps to reproduce:
- Open a terminal
- Run
DEBUG=cypress:* npx cypress@latest verify
(getting the same output if one were to runDEBUG=cypress:* yarn cypress verify
in their project directory)
Versions
Node@LTS (v12.14.0)
Cypress@latest (v3.8.1)
macOS High Sierra (v10.13.6)