cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.02k stars 3.18k forks source link

Can't launch the first run: missing dependencies on a fresh install on Mac OS #27033

Closed lionelrudaz closed 1 year ago

lionelrudaz commented 1 year ago

Current behavior

No issue downloading Cypress. It's installed with the version 12.14.0.

The issue comes when I need to launch my first run as part of the onboarding.

Trying to launch my first run with the provided line from the onboarding.

npx cypress run --record --key this-is-my-key

I've got a link to required dependencies, but there's nothing related to Mac OS in the article.

Debug logs

It looks like this is your first time using Cypress: 12.14.0

Cypress failed to start.

This may be due to a missing library or dependency. https://on.cypress.io/required-dependencies

Please refer to the error below for more details.

----------

/Users/lionel/Library/Caches/Cypress/12.14.0/Cypress.app/Contents/MacOS/Cypress: bad option: --no-sandbox
/Users/lionel/Library/Caches/Cypress/12.14.0/Cypress.app/Contents/MacOS/Cypress: bad option: --smoke-test
/Users/lionel/Library/Caches/Cypress/12.14.0/Cypress.app/Contents/MacOS/Cypress: bad option: --ping=3

----------

Platform: darwin-arm64 (22.5.0)
Cypress Version: 12.14.0

Cypress Version

12.14.0

Node version

19.1.0

Package Manager

yarn

Package Manager Version

3.3.0

Operating system

Mac

Operating System Version

Ventura 13.4 / darwin-arm64 (22.5.0)

Other

Let me know if I can provide anything else useful.

warrensplayer commented 1 year ago

@lionelrudaz Can you try running Cypress in open mode first? npx cypress open See if that opens and then try running your same command again.

lionelrudaz commented 1 year ago

Thanks @warrensplayer for your answer.

I've tried the command and got the same result.

It looks like this is your first time using Cypress: 12.14.0

Cypress failed to start.

This may be due to a missing library or dependency. https://on.cypress.io/required-dependencies

Please refer to the error below for more details.

----------

/Users/lionel/Library/Caches/Cypress/12.14.0/Cypress.app/Contents/MacOS/Cypress: bad option: --no-sandbox
/Users/lionel/Library/Caches/Cypress/12.14.0/Cypress.app/Contents/MacOS/Cypress: bad option: --smoke-test
/Users/lionel/Library/Caches/Cypress/12.14.0/Cypress.app/Contents/MacOS/Cypress: bad option: --ping=198

----------

Platform: darwin-arm64 (22.5.0)
Cypress Version: 12.14.0
raghwendra-sonu commented 1 year ago

I am also facing this issue with cypress 12.14 version

> npx cypress open
It looks like this is your first time using Cypress: 12.14.0

Cypress failed to start.

This may be due to a missing library or dependency. https://on.cypress.io/required-dependencies

Please refer to the error below for more details.

----------

Command failed with UNKNOWN: \Cypress\Cache\12.14.0\Cypress\Cypress.exe --smoke-test --ping=942
spawn UNKNOWN

----------
warrensplayer commented 1 year ago

@lionelrudaz and @raghwendra-sonu Can either of you please share more detail on the steps you took to get this error? Can you share a simple reproduction that exhibits this error?

lionelrudaz commented 1 year ago

Hey @warrensplayer, thanks for the reply. I'm afraid there's no much to say.

I've followed the Installation instructions: https://docs.cypress.io/guides/getting-started/installing-cypress

I've typed yarn add cypress --dev, then npx cypress open

I've also followed the instructions from the onboarding.

Let me know if you need more information.

warrensplayer commented 1 year ago

@raghwendra-sonu It kind of looks like your issue might be different. Can you file a new bug issue and fill out all the sections with your information?

warrensplayer commented 1 year ago

@lionelrudaz Does this happen for any new npm project? Can you reproduce it with an older version of Cypress or does it just happen with 12.14.0?

mike-plummer commented 1 year ago

@lionelrudaz Can you also see if you get the same result using yarn cypress open instead of using npx? Yarn v3 has a very different way of handling dependency resolution and I'm not sure how well that plays with npx, particularly if you have a parent project or a global version of a package installed

lionelrudaz commented 1 year ago

Thanks @warrensplayer and @mike-plummer

I've downgraded to 12.13, tried to open with yarn, same result. Let me know if you need more details.

CleanShot 2023-06-20 at 19 59 28@2x
mike-plummer commented 1 year ago

@lionelrudaz I've attempted to replicate this with the exact same Node, Yarn, MacOS, and Cypress version but everything works fine for me. 😓 I have a couple thoughts on next steps:

  1. Are you using a non-standard shell (something other than zsh or bash)?
  2. Can you try deleting the Cypress cache? cypress cache clear (hopefully that command doesn't blow up 😬 ) then re-run yarn to reinstall Cypress
  3. Do you see the same issue using npm vs yarn?
lionelrudaz commented 1 year ago

Hi @mike-plummer, thanks for following that up.

  1. Yes, I'm using zsh in VS Code
  2. Done and done. Now I'm running 12.15 :)
  3. Yes same issue

Everything is in the screenshot below.

CleanShot 2023-06-22 at 10 46 32@2x
mike-plummer commented 1 year ago

@lionelrudaz I'm at a bit of a loss - I've replicated your scenario as exactly as I can and still can't see a failure. Just to summarize to make sure I'm not missing anything:

At this point I'm wondering whether there's some project-specific configuration that's causing Node or Yarn to work differently. For example, in the screenshot below there's a ESM support for PnP uses the experimental loader API and is therefore experimental warning that I don't see in your output, and obviously you have dependencies that I don't have in my empty scaffold.

Image

Have you tried enabling Debug Logs? This error happens so early I'm not sure whether we'll get any useful info.

Is it possible you have some environment variables being set (for example ELECTRON_RUN_AS_NODE which has been linked with this behavior in the past)?

Can you share the project this is happening on so I can try to reproduce? Do you see the same behavior on an empty project?

mkdir my-cypress-test cd my-cypress-test npm init yarn add cypress --dev yarn run cypress open

The other thought I have is a potentially-corrupted/incomplete NPM package in your npx and/or yarn caches, those are separate from the Cypress cache you cleared earlier (which only contains the binaries we download as part of install).

mike-plummer commented 1 year ago

Unfortunately we have to close this issue due to inactivity. Please comment if there is new information to provide concerning the original issue and we can reopen.

lionelrudaz commented 1 year ago

Hey @mike-plummer

Sorry for the late answer, I was off for a week for my wedding 😃

Here's the result of the Debug mode:

CleanShot 2023-06-29 at 17 14 05@2x

I have also tested on a new project, and it works just fine, so there's something not working specifically with my project.

Here's the content of my package.json, perhaps this helps.

{
  "name": "tasters",
  "version": "1.0.0",
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start",
    "test": "jest --watch",
    "test:e2e": "playwright test"
  },
  "dependencies": {
    "@crystallize/content-transformer": "^9.0.0",
    "@crystallize/react-content-transformer": "^2.0.0",
    "@crystallize/reactjs-components": "^1.4.1",
    "@headlessui/react": "^1.7.14",
    "@liveblocks/client": "^1.0.2",
    "@liveblocks/react": "^1.0.2",
    "@next-auth/prisma-adapter": "^1.0.1",
    "@phosphor-icons/react": "^2.0.10",
    "@prisma/client": "^3.7.0",
    "@stripe/stripe-js": "^1.11.0",
    "@tailwindcss/forms": "^0.4.0",
    "@tailwindcss/typography": "^0.5.0",
    "@testing-library/jest-dom": "^5.16.2",
    "@testing-library/react": "^12.1.3",
    "@vercel/analytics": "^1.0.0",
    "@vercel/og": "^0.0.25",
    "animejs": "^3.2.1",
    "autoprefixer": "^10.4.0",
    "avvvatars-react": "^0.4.2",
    "chart.js": "^4.2.0",
    "cloudinary": "^1.26.1",
    "gray-matter": "^4.0.2",
    "jest": "^27.5.1",
    "jwt-encode": "^1.0.1",
    "mapbox-gl": "^2.10.0",
    "next": "latest",
    "next-auth": "^4.22.1",
    "nodemailer": "^6.7.2",
    "nprogress": "^0.2.0",
    "pg": "^8.7.1",
    "pg-hstore": "^2.3.4",
    "phosphor-react": "^1.4.0",
    "postcss": "^8.4.5",
    "react": "latest",
    "react-animejs": "^0.5.6",
    "react-chartjs-2": "^5.2.0",
    "react-dom": "latest",
    "react-hook-form": "^7.38.0",
    "react-multi-carousel": "^2.6.3",
    "react-select": "^5.2.2",
    "react-toastify": "^9.1.1",
    "remark": "^13.0.0",
    "remark-html": "^13.0.1",
    "sass": "^1.29.0",
    "stripe": "^8.119.0"
  },
  "devDependencies": {
    "@playwright/test": "^1.34.3",
    "@types/node": "^18.7.16",
    "@types/react": "^18.0.18",
    "cypress": "^12.15.0",
    "eslint": "^7.31.0",
    "eslint-config-next": "latest",
    "postcss-flexbugs-fixes": "4.2.1",
    "postcss-preset-env": "^6.7.0",
    "prisma": "^3.7.0",
    "tailwindcss": "latest",
    "typescript": "^4.8.4"
  },
  "license": "MIT"
}

Let me know if you need more information.

mike-plummer commented 1 year ago

Thanks for the info @lionelrudaz , and congrats on the wedding! I'll take a look later today, see if I can reproduce

lionelrudaz commented 1 year ago

Thanks very much, it's really appreciated. Let me know if there's anything I can do to help.

mike-plummer commented 1 year ago

@lionelrudaz Ha ha! I finally managed to reproduce your issue. I see this line in your latest screenshot:

Environment variable ELECTRON_RUN_AS_NODE detected, xvfb is not needed

That environment variable has been linked with this behavior in the past - could you try unsetting it and see what happens?

unset ELECTRON_RUN_AS_NODE or see if it's hiding in an .env file in your project maybe

lionelrudaz commented 1 year ago

Thanks @mike-plummer, unfortunately unset ELECTRON_SET_AS_NODE didn't work, and I haven't seen anything related to Electron in my code, except in yarn.lock file for dependencies with electron-to-chromium.

I see nothing related to ELECTRO_SET_AS_NODE in my zsh env variables neither.

mike-plummer commented 1 year ago

@lionelrudaz Oops, mistyped the variable name - should be ELECTRON_RUN_AS_NODE. Updated my earlier comment for posterity

lionelrudaz commented 1 year ago

Thanks a lot @mike-plummer, it's working 🥳

mike-plummer commented 1 year ago

@lionelrudaz Fabulous! Glad it got sorted out, thanks for using Cypress!