Not sure if this really has to do with yarn (v2) but adding the latest cypress version to a project fails for me. It successfully installs when I use npm.
Stacktrace:
➤ YN0000: ┌ Link step
➤ YN0007: │ cypress@npm:4.0.0 must be built because it never did before or the last one failed
➤ YN0009: │ cypress@npm:4.0.0 couldn't be built successfully (exit code 1, logs can be found here: /var/folders/4r/fbk_4j8d3ss5xl8975901nhr0000gp/T/logfile-6119EAzUDTs6CGBm.log)
Content of logfile-6119EAzUDTs6CGBm.log:
# This file contains the result of Yarn building a package (cypress@npm:4.0.0)
# Script name: postinstall
/.../test-cypress/.yarn/cache/any-observable-npm-0.3.0-4832f4f3ed-1.zip/node_modules/any-observable/register.js:29
throw new Error('Cannot find any-observable implementation nor' +
^
Error: Cannot find any-observable implementation nor global.Observable. You must install polyfill or call require("any-observable/register") with your preferred implementation, e.g. require("any-observable/register")('rxjs') on application load prior to any require("any-observable").
at loadImplementation (/..../test-cypress/.yarn/cache/any-observable-npm-0.3.0-4832f4f3ed-1.zip/node_modules/any-observable/register.js:29:9)
at /...../test-cypress/.yarn/cache/any-observable-npm-0.3.0-4832f4f3ed-1.zip/node_modules/any-observable/loader.js:30:18
at Object.<anonymous> (/..../test-cypress/.yarn/cache/any-observable-npm-0.3.0-4832f4f3ed-1.zip/node_modules/any-observable/index.js:2:39)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.module_1.Module._load (/..../test-cypress/.pnp.js:15569:14)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/..../test-cypress/.yarn/cache/@samverschueren-stream-to-observable-npm-0.3.0-3da2ac7de0-1.zip/node_modules/@samverschueren/stream-to-observable/index.js:2:20)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.module_1.Module._load (/..../test-cypress/.pnp.js:15569:14)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
A succesfull install
New folder
yarn init
yarn add --dev [email protected]
yarn : 2.0.0-rc.27
cypress: 4.0.0
OS: macOS Catalina 10.15.3
I ran into this - it seems like an error with a dependency relying on an older version of rxjs. Installing rxjs and rxjs-compat seems to work around this.
@gvdp can you confirm if the workaround provided by @jenkshields fixed your issue?
I can add that in my case install the dependencies will allow to avoid that error but if you run
yarn cypress open
the binary starts but the window doesn't show.
The only way to see the window is to run
npx cypress open
I'm not able to recreate the installation error with Cypress 4.0.2 (or 3.8.3) and yarn 2.
yarn add cypress
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 3.37s
➤ YN0000: ┌ Fetch step
➤ YN0013: │ which@npm:2.0.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ wrap-ansi@npm:3.0.1 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ wrappy@npm:1.0.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yauzl@npm:2.10.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yauzl@npm:2.4.1 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed in 7.11s
➤ YN0000: ┌ Link step
➤ YN0007: │ cypress@npm:4.0.2 must be built because it never did before or the last one failed
➤ YN0000: └ Completed in 1.75s
➤ YN0000: Done in 12.23s
I am able to recreate the 'hanging' when running yarn cypress open. I have to manually force quit the Cypress process
Debug logs:
DEBUG=cypress:* yarn cypress open
cypress:cli:cli cli starts with arguments ["/Users/jennifer/.nvm/versions/node/v12.8.1/bin/node","/Users/jennifer/Dev/yarn-test/.yarn/unplugged/cypress-npm-4.0.2-9b440563c1/node_modules/cypress/bin/cypress","open"] +0ms
cypress:cli NODE_OPTIONS=--require /Users/jennifer/Dev/yarn-test/.pnp.js +0ms
cypress:cli:cli program parsing arguments +1ms
cypress:cli:cli opening Cypress +1ms
cypress:cli parsed cli options {} +175ms
cypress:cli opening from options {"project":"/Users/jennifer/Dev/yarn-test"} +0ms
cypress:cli command line arguments ["--project","/Users/jennifer/Dev/yarn-test"] +0ms
cypress:cli verifying Cypress app +0ms
cypress:cli checking environment variables +1ms
cypress:cli checking if executable exists /Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/MacOS/Cypress +2ms
cypress:cli Binary is executable? : true +1ms
cypress:cli binaryDir is /Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app +0ms
cypress:cli Reading binary package.json from: /Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/Resources/app/package.json +0ms
cypress:cli Found binary version 4.0.2 installed in: /Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app +2ms
cypress:cli { verified: true } +3ms
cypress:cli is Verified ? true +1ms
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: /Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/MacOS/Cypress +2ms
cypress:cli spawn args [ '--no-sandbox', '--', '--project', '/Users/jennifer/Dev/yarn-test', '--cwd', '/Users/jennifer/Dev/yarn-test' ] { detached: false, stdio: 'inherit' } +0ms
cypress:ts Running without ts-node hook in environment "production" +0ms
cypress:server:appdata path: /Users/jennifer/Library/Application Support/Cypress/cy/production/browsers +0ms
cypress:server:cypress starting cypress with argv [ '/Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/MacOS/Cypress', '--no-sandbox', '--', '--project', '/Users/jennifer/Dev/yarn-test', '--cwd', '/Users/jennifer/Dev/yarn-test' ] +0ms
cypress:server:args argv array: [ '/Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/MacOS/Cypress', '--no-sandbox', '--project', '/Users/jennifer/Dev/yarn-test', '--cwd', '/Users/jennifer/Dev/yarn-test' ] +0ms
cypress:server:args argv parsed: { _: [ '/Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/MacOS/Cypress' ], sandbox: false, project: '/Users/jennifer/Dev/yarn-test', cwd: '/Users/jennifer/Dev/yarn-test', invokedFromCli: true } +3ms
cypress:server:util:proxy found proxy environment variables {} +0ms
cypress:server:args options { _: [ '/Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/MacOS/Cypress' ], sandbox: false, project: '/Users/jennifer/Dev/yarn-test', cwd: '/Users/jennifer/Dev/yarn-test', invokedFromCli: true, config: {} } +1ms
cypress:server:args argv options: { _: [ '/Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/MacOS/Cypress' ], sandbox: false, project: '/Users/jennifer/Dev/yarn-test', cwd: '/Users/jennifer/Dev/yarn-test', invokedFromCli: true, config: {}, projectRoot: '/Users/jennifer/Dev/yarn-test' } +0ms
cypress:server:cypress from argv [ '/Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/MacOS/Cypress', '--no-sandbox', '--project', '/Users/jennifer/Dev/yarn-test', '--cwd', '/Users/jennifer/Dev/yarn-test' ] got options { _: [ '/Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/MacOS/Cypress' ], sandbox: false, project: '/Users/jennifer/Dev/yarn-test', cwd: '/Users/jennifer/Dev/yarn-test', invokedFromCli: true, config: {}, projectRoot: '/Users/jennifer/Dev/yarn-test' } +5ms
cypress:server:appdata path: /Users/jennifer/Library/Application Support/Cypress/cy/production +344ms
cypress:server:cypress starting in mode interactive with options { _: [ '/Users/jennifer/Library/Caches/Cypress/4.0.2/Cypress.app/Contents/MacOS/Cypress' ], sandbox: false, project: '/Users/jennifer/Dev/yarn-test', cwd: '/Users/jennifer/Dev/yarn-test', invokedFromCli: true, config: {}, projectRoot: '/Users/jennifer/Dev/yarn-test' } +120ms
cypress:server:cypress running Electron currently +26ms
cypress:server:appdata path: /Users/jennifer/Library/Application Support/Cypress/cy/production +4s
cypress:server:appdata path: /Users/jennifer/Library/Application Support/Cypress/cy/production/cache +45s
--- Cypress just hangs forever using up 100%+ CPU

I had this same issue, but ultimately resolved it. Here's what I found.
yarn set version berryyarn add cypress and it should install fine.That resolves the initial issue. But something else to note in how Cypress works with Yarn 2, it seems that when you run Cypress (npx cypress open), even if you're in the project directory that has your tests, it doesn't load up that project by default, you have to manually select your project.
@AStoker Thanks for the followup. This would explain why I was not able to replicate as I did not install Yarn 2 globally as they advise.
We do recommend the workaround in this comment for installing on Yarn 2 https://github.com/cypress-io/cypress/issues/6377#issuecomment-592742158
We will leave this issue open for the yarn cypress open issue however.
Also @AStoker - make sure you do not have cypress globally installed as this is the behavior if you have cypress globally installed - to open Cypress and allow you to select project.
@AStoker @jennifer-shehane Hello, I wasn't able to fix the problem with the steps provided.
I have only yarn 1.x installed locally yarn 1.22.0
Here's the list of the commands I've executed to reproduce the issue
mkdir test-project
cd test-project/
yarn init
yarn set version berry
yarn add cypress
yarn cypress open
I've waited for more than a minute and the Cypress window did not appear for me.
My OS details:
OS: Ubuntu 18.04 bionic
Kernel: x86_64 Linux 5.3.0-40-generic
@jennifer-shehane, do you have any tips about debugging this (or is somebody already on it)? I'm not afraid to spend a bit of time trying to help identify what is going on (not sure if I'll be able to solve it though, but hey, that's how open source works, everybody together). However, I'm not familiar with how Cypress hooks into the yarn to be run (and therefore listen to any debug statements). Is there a place you'd recommend I start looking?
Also, if it's any help, I ran yarn cypress open and just left it (forgot about it honestly) and eventually came back about 30 minutes later and found that the window had actually opened up. Nothing was loaded, just had the title bar, but it did actually have something loaded.
Edit: Timed it this time, took about 15 minutes for it to open to the empty Cypress window
I can confirm this problem on my Windows 10 Pro 10.0.18363 machine with the reproduction provided by @DanAtSpark.
Adding some additional details (and a workaround) for those of you who are on Yarn 2. I haven't been able to figure out exactly how Cypress starts its execution, but I was thinking that potentially the issue was revolving around node trying to identify all the modules required to actually run. Since Yarn 2 doesn't have a node_modules folder and by default uses the PnP setup, I thought that maybe Node was doing what it does when it can't find a library, it goes to the parent directory and looks to see if it has a node_modules folder containing what it needs, and up and up it goes.
So I decided to tell yarn to place the node_modules folder back in the directory by adding the nodeLinker plugin as recommended by the Yarn site. Now, when you run yarn install again, it will place all the node modules back into a folder as in Yarn 1. At this point, when running yarn cypress open it will work as expected.
In the end, I'd still like to figure out what is exactly happening here and get Cypress to run with the default PnP setup.
I think https://github.com/cypress-io/cypress/issues/6378 is a duplicate of this one.
I made a comment here: https://github.com/cypress-io/cypress/issues/6378#issuecomment-614591409 I have the same issue but I'm not using yarn 2.
Removing node_modules, cleaning cypress cache, trying to use cypress 3.6.0 or cypress 4.4.0... Nothing works locally anymore
@maxime1992 please see my comment https://github.com/cypress-io/cypress/issues/6378#issuecomment-617552586 - your issue is unrelated to the yarn issue. Upgrade to 4.4.1 to get a fix.
@AStoker Your solution is temporary and cypress should support built-in yarn 2 (PNP algorithm) and it's really important.
We use yarn 2 for the zero-install feature to improve our CI build time, and If we use nodeLinker, we miss that feature.
cc: @arcanis Do you have any plan to support cypress?
cc: @arcanis Do you have any plan to support cypress?
I don't use Cypress myself, so I don't plan to dig into that.
Most helpful comment
Adding some additional details (and a workaround) for those of you who are on Yarn 2. I haven't been able to figure out exactly how Cypress starts its execution, but I was thinking that potentially the issue was revolving around node trying to identify all the modules required to actually run. Since Yarn 2 doesn't have a node_modules folder and by default uses the PnP setup, I thought that maybe Node was doing what it does when it can't find a library, it goes to the parent directory and looks to see if it has a node_modules folder containing what it needs, and up and up it goes.
So I decided to tell yarn to place the node_modules folder back in the directory by adding the nodeLinker plugin as recommended by the Yarn site. Now, when you run
yarn installagain, it will place all the node modules back into a folder as in Yarn 1. At this point, when runningyarn cypress openit will work as expected.In the end, I'd still like to figure out what is exactly happening here and get Cypress to run with the default PnP setup.