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

Installation fails when installing two different versions of Cypress during the same yarn install step. #7951

Closed
Vages opened this issue Jul 10, 2020 · 1 comment
Labels
type: duplicate This issue or pull request already exists

Comments

@Vages
Copy link

Vages commented Jul 10, 2020

Current behavior:

  • Installation fails when installing two different versions of Cypress during the same yarn install step.
    • My machine is a Mac.
    • I am not behind any kind of proxy.
    • I have also experienced this problem in CircleCi (see "Example output from CircleCI")
  • Yes, this is a wall of text
    • Don't worry; it's just the examples.
  • The examples will be using Cypress v4.5.0 and v4.10.0.
    • One will be a direct dependency. The other will be a transitive dependency through the most recent version of @testing-library/cypress.
  • Let me know if I can be of any help.

In a nutshell

  • @testing-library/cypress has the dependency @types/testing-library__cypress. The latter's package.json includes the dependency "cypress": "*".
  • In npm semantic versioning, * means "any version".
    • yarn install seems to resolve * as the most recent Cypress version, 4.10.0 (see "Working example 5")
    • ... unless a less recent version is installed afterwards. (see "Working example 4")
    • Running a yarn upgrade will re-resolve cypress@* as the most recent version. (see "Working example 4")
    • npm install seems to resolve cypress@* as the same version as any other installed version, if one exists (see "Working example 1").
  • When cypress/cli/lib/tasks/download.js tries downloading two different versions during the same yarn install step, there is a mismatch between the expected and calculated checksums for whichever of two different versions is downloaded first (usually 4.5.0, see "Further notes").
    • Yarn quits as a result.
  • Installing in two steps (see "Working example 4" and "Working example 5") removes the error.
  • If Cypress has cached versions of the downloads, there are no problems.

Desired behavior:

I want "Non working example 1" (below) to work without quitting.

Test code to reproduce

Reproducing the problem

Warning: The examples make use of a ~/directAndTransitiveCypress folder. If you have a folder with this name, back it up.

Non-working example 1: Older direct dependency, newest transitive

cd ~
rm -rf directAndTransitiveCypress
npx cypress cache clear # I had to put "npx" in front in order for cypress to be found
mkdir directAndTransitiveCypress
cd directAndTransitiveCypress
npm init --yes # Accept all the defaults
yarn add -D cypress@4.5.0 @testing-library/cypress
Wrote to /Users/foo/directAndTransitiveCypress/package.json:

{
  "name": "directAndTransitiveCypress",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}


yarn add v1.22.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
[1/3] ⠂ cypress
[-/3] ⠂ waiting...
error /Users/foo/directAndTransitiveCypress/node_modules/cypress: Command failed.
Exit code: 1
Command: node index.js --exec install
Arguments: 
Directory: /Users/foo/directAndTransitiveCypress/node_modules/cypress
Output:
Installing Cypress (version: 4.5.0)

[17:05:56]  Downloading Cypress     [started]
[17:05:57]  Downloading Cypress      0% 0s [title changed]
[17:05:57]  Downloading Cypress      1% 40s [title changed]
...
[17:06:22]  Downloading Cypress      99% 0s [title changed]
[17:06:23]  Downloading Cypress      100% 0s [title changed]
[17:06:23]  Downloading Cypress      100% 0s [failed]
[17:06:23] → The Cypress App could not be downloaded.

Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration

Otherwise, please check network connectivity and try again:

----------

URL: https://download.cypress.io/desktop/4.5.0?platform=darwin&arch=x64
Error: Corrupted download

Expected downloaded file to have checksum: a120e416f6e3ed7909d7e36adae8f57a6144a530a13ef1f16e5b475de27e3b68f0ad13abd11d1a263ffada37c24ebfa2d610a25fc2390e53fe23d6c05480e454
Computed checksum: 530c1e9e35c7c24411983ac09a944028ce75b7618a7d6e189e9f11738d120899b87761647b6a71598d1b1bbd6bf9bff0d67a9c2e913000c50fa75e27f75913af

Expected downloaded file to have size: 174378580
Computed size: 174378580

----------

Platform: darwin (19.5.0)
Cypress Version: 4.5.0
The Cypress App could not be downloaded.

Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration

Otherwise, please check network connectivity and try again:

----------

URL: https://download.cypress.io/desktop/4.5.0?platform=darwin&arch=x64
Error: Corrupted download

Expected downloaded file to have checksum: a120e416f6e3ed7909d7e36adae8f57a6144a530a13ef1f16e5b475de27e3b68f0ad13abd11d1a263ffada37c24ebfa2d610a25fc2390e53fe23d6c05480e454
Computed checksum: 530c1e9e35c7c24411983ac09a944028ce75b7618a7d6e189e9f11738d120899b87761647b6a71598d1b1bbd6bf9bff0d67a9c2e913000c50fa75e27f75913af

Expected downloaded file to have size: 174378580
Computed size: 174378580

----------

Platform: darwin (19.5.0)

Non-working example 2: Newest as direct, older as transitive

Using selective version resolutions, we specify that the transitive Cypress will the older version (4.5.0), and the direct the newer (4.10.0). This requires a pre-made package.json-file (see the echo step).

cd ~
rm -rf directAndTransitiveCypress
npx cypress cache clear # I had to put "npx" in front in order for cypress to be found
mkdir directAndTransitiveCypress
cd directAndTransitiveCypress
echo '{"name":"directandtransitivecypress","version":"1.0.0","description":"","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"resolutions":{"@testing-library/**/cypress":"4.5.0"},"author":"","license":"ISC","devDependencies":{"@testing-library/cypress":"^6.0.0","cypress":"4.10.0"}}' > package.json
yarn
yarn install v1.22.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
[-/4] ⠐ waiting...
[2/4] ⠐ cypress
[3/4] ⠐ cypress
error /Users/foo/directAndTransitiveCypress/node_modules/@testing-library/cypress/node_modules/cypress, /Users/foo/directAndTransitiveCypress/node_modules/@types/testing-library__cypress/node_modules/cypress: Command failed.
Exit code: 1
Command: node index.js --exec install
Arguments: 
Directory: /Users/foo/directAndTransitiveCypress/node_modules/@testing-library/cypress/node_modules/cypress
Output:
Installing Cypress (version: 4.5.0)

[17:53:59]  Downloading Cypress     [started]
[17:53:59]  Downloading Cypress      0% 0s [title changed]
[17:54:00]  Downloading Cypress      1% 30s [title changed]
...
[17:54:32]  Downloading Cypress      99% 0s [title changed]
[17:54:33]  Downloading Cypress      99% 0s [failed]
[17:54:33] → The Cypress App could not be downloaded.

Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration

Otherwise, please check network connectivity and try again:

----------

URL: https://download.cypress.io/desktop/4.5.0?platform=darwin&arch=x64
Error: Corrupted download

Expected downloaded file to have checksum: a120e416f6e3ed7909d7e36adae8f57a6144a530a13ef1f16e5b475de27e3b68f0ad13abd11d1a263ffada37c24ebfa2d610a25fc2390e53fe23d6c05480e454
Computed checksum: 4f23309e4c5a3f9cc570a3e9e502216f24b2b63404ceded5fb20d4a1267287ca05a09a9a816c73856f0a5f6a4bf9bd741e96f06abce73910e395760ffe1b3918

Expected downloaded file to have size: 174378580
Computed size: 174378580

----------

Platform: darwin (19.5.0)
Cypress Version: 4.5.0
The Cypress App could not be downloaded.

Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration

Otherwise, please check network connectivity and try again:

----------

URL: https://download.cypress.io/desktop/4.5.0?platform=darwin&arch=x64
Error: Corrupted download

Expected downloaded file to have checksum: a120e416f6e3ed7909d7e36adae8f57a6144a530a13ef1f16e5b475de27e3b68f0ad13abd11d1a263ffada37c24ebfa2d610a25fc2390e53fe23d6c05480e454
Computed checksum: 4f23309e4c5a3f9cc570a3e9e502216f24b2b63404ceded5fb20d4a1267287ca05a09a9a816c73856f0a5f6a4bf9bd741e96f06abce73910e395760ffe1b3918

Expected downloaded file to have size: 174378580
Computed size: 174378580

----------

Fixing/circumventing the problem

Working example 1: Use NPM instead of yarn

cd ~
rm -rf directAndTransitiveCypress
npx cypress cache clear # I had to put "npx" in front in order for cypress to be found
mkdir directAndTransitiveCypress
cd directAndTransitiveCypress
npm init --yes # Accept all the defaults
npm install -D cypress@4.5.0 @testing-library/cypress
> core-js-pure@3.6.5 postinstall /Users/foo/directAndTransitiveCypress/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> cypress@4.5.0 postinstall /Users/foo/directAndTransitiveCypress/node_modules/cypress
> node index.js --exec install

Installing Cypress (version: 4.5.0)

  ✔  Downloaded Cypress
  ✔  Unzipped Cypress
  ✔  Finished Installation /Users/foo/Library/Caches/Cypress/4.5.0

You can now open Cypress by running: node_modules/.bin/cypress open

https://on.cypress.io/installing-cypress

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN directandtransitivecypress@1.0.0 No description
npm WARN directandtransitivecypress@1.0.0 No repository field.

+ cypress@4.5.0
+ @testing-library/cypress@6.0.0
added 251 packages from 231 contributors and audited 251 packages in 54.516s

4 packages are looking for funding
  run `npm fund` for details

found 2 low severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details

Notes

Looking at package-lock.json afterwards, both cypress requirements seem to have resolved to 4.5.0

Working example 2: Installing the most recent version of Cypress using yarn

cd ~
rm -rf directAndTransitiveCypress
npx cypress cache clear # I had to put "npx" in front in order for cypress to be found
mkdir directAndTransitiveCypress && cd directAndTransitiveCypress
npm init --yes # Accept all the defaults
yarn add -D cypress @testing-library/cypress
yarn add v1.22.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
success Saved 180 new dependencies.
info Direct dependencies
├─ @testing-library/cypress@6.0.0
└─ cypress@4.10.0
info All dependencies
├─ @babel/runtime-corejs3@7.10.4
├─ @babel/runtime@7.10.4
...
├─ wrap-ansi@3.0.1
└─ yauzl@2.10.0
✨  Done in 44.60s.

Working example 3: Force @testing-library/cypress' transitive cypress dependency to be of the same, older version as cypress

Again using selective version resolutions.

cd ~
rm -rf directAndTransitiveCypress
npx cypress cache clear # I had to put "npx" in front in order for cypress to be found
mkdir directAndTransitiveCypress
cd directAndTransitiveCypress
echo '{"name":"directandtransitivecypress","version":"1.0.0","description":"","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"resolutions":{"@testing-library/**/cypress":"4.5.0"},"author":"","license":"ISC","devDependencies":{"@testing-library/cypress":"^6.0.0","cypress":"4.5.0"}}' > package.json
yarn
yarn install v1.22.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
✨  Done in 50.95s.

Working example 4: Separate non-working-example 1 steps; install testing library first

cd ~
rm -rf directAndTransitiveCypress
npx cypress cache clear # I had to put "npx" in front in order for cypress to be found
mkdir directAndTransitiveCypress
cd directAndTransitiveCypress
npm init --yes # Accept all the defaults
yarn add -D @testing-library/cypress
yarn add -D cypress@4.5.0
Wrote to /Users/foo/directAndTransitiveCypress/package.json:

{
  "name": "directAndTransitiveCypress",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}


yarn add v1.22.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning " > @testing-library/cypress@6.0.0" has unmet peer dependency "cypress@^2.1.0 || ^3.0.0 || ^4.0.0".
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
success Saved 180 new dependencies.
info Direct dependencies
└─ @testing-library/cypress@6.0.0
info All dependencies
├─ @babel/runtime-corejs3@7.10.4
...
└─ yauzl@2.10.0
✨  Done in 46.67s.
yarn add v1.22.4
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
success Saved 19 new dependencies.
info Direct dependencies
└─ cypress@4.5.0
info All dependencies
├─ @types/blob-util@1.3.3
...
└─ path-is-inside@1.0.2
✨  Done in 40.94s.

Notes

Looking at yarn.lock afterwards, I found both dependencies had resolved to 4.5.0.

cypress@*, cypress@4.5.0:
  version "4.5.0"

If you run yarn upgrade afterwards and then inspect yarn.lockI found that the transitive dependency had resolved to 4.10.0

cypress@*:
  version "4.10.0"

The direct dependency, however, stayed at 4.5.0.

cypress@4.5.0:
  version "4.5.0"

Working example 5: Installing the oldest version first

cd ~
rm -rf directAndTransitiveCypress
npx cypress cache clear # I had to put "npx" in front in order for cypress to be found
mkdir directAndTransitiveCypress
cd directAndTransitiveCypress
npm init --yes # Accept all the defaults
yarn add -D cypress@4.5.0
yarn add -D @testing-library/cypress
Wrote to /Users/foo/directAndTransitiveCypress/package.json:

{
  "name": "directAndTransitiveCypress",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}


yarn add v1.22.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
success Saved 172 new dependencies.
info Direct dependencies
└─ cypress@4.5.0
info All dependencies
├─ @cypress/listr-verbose-renderer@0.4.1
...
└─ yauzl@2.10.0
✨  Done in 42.27s.
yarn add v1.22.4
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
success Saved 20 new dependencies.
info Direct dependencies
└─ @testing-library/cypress@6.0.0
info All dependencies
├─ @babel/runtime-corejs3@7.10.4
...
└─ react-is@16.13.1
✨  Done in 42.45s.

Notes

Looking in yarn.lock afterwards, I found that the transitive dependency had resolved to 4.10.0

cypress@*:
  version "4.10.0"

The direct dependency, however, resolved to 4.5.0.

cypress@4.5.0:
  version "4.5.0"

Running yarn upgrade afterwards did not change this.

Versions

The versions used in the examples were 4.5.0 and 4.10.0.

Software Version
MacOS 10.15.5 (19F101)
yarn 1.22.4
node 12.18.2
npm 6.14.5

Further notes

Related places in the codebase

I think the clues to solving this lie near the following lines:

4.10.0 is installed before 4.9.0

Using non-working example 1, I have tried replacing the direct version of Cypress with more recent minors. At exactly 4.9.0, version 4.10.0 is installed first. This doe

Direct dependency version Version it first tries installing (and fails at)
4.9.0 4.10.0
4.8.0 4.8.0
4.7.0 4.7.0
4.6.0 4.6.0

Expected checksums are the same every time, but the calculated checksums differ

I have run these scripts over and over, and the expected checksum for 4.5.0 is always a120e416f6e3ed7909d7e36adae8f57a6144a530a13ef1f16e5b475de27e3b68f0ad13abd11d1a263ffada37c24ebfa2d610a25fc2390e53fe23d6c05480e454

I have opened https://download.cypress.io/desktop/4.5.0?platform=darwin&arch=x64 in my browser and verified that, after a redirect to https://cdn.cypress.io/desktop/4.5.0/darwin-x64/cypress.zip, this value can be found in the header x-amz-meta-checksum.

The calculated checksums seem to differ every time. You can see this in non-working examples 1 and 2.

Example output from CircleCI

What originally prompted me to follow up on this error was the following problems in a CircleCI with a direct dependency on v4.5.0 and a transitive dependency on 4.10.0.

yarn install --frozen-lockfile 

yarn install v1.21.1
 
[1/4] Resolving packages...
 
[2/4] Fetching packages...
 
warning sha.js@2.4.11: Invalid bin entry for "sha.js" (in "sha.js").
 
info fsevents@2.1.3: The platform "linux" is incompatible with this module.
 
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
 
info fsevents@1.2.13: The platform "linux" is incompatible with this module.
 
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
 
[3/4] Linking dependencies...
 
warning "enzyme-adapter-react-16 > react-test-renderer@16.13.1" has incorrect peer dependency "react@^16.13.1".
 
warning "eslint-config-airbnb > eslint-config-airbnb-base@14.2.0" has incorrect peer dependency "eslint-plugin-import@^2.21.2".
 
warning "eslint-plugin-functional > @typescript-eslint/experimental-utils > @typescript-eslint/typescript-estree > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
 
warning " > eslint-plugin-unicorn@20.1.0" has incorrect peer dependency "eslint@>=7.0.0".
 
warning "eslint-plugin-unicorn > eslint-template-visitor@2.2.1" has incorrect peer dependency "eslint@>=7.0.0".
 
[4/4] Building fresh packages...
 
error /home/circleci/project/node_modules/@types/testing-library__cypress/node_modules/cypress: Command failed.
 
Exit code: 1
 
Command: node index.js --exec install
 
Arguments: 
 
Directory: /home/circleci/project/node_modules/@types/testing-library__cypress/node_modules/cypress
 
Output:
 
Installing Cypress (version: 4.10.0)
 

 
[13:51:17]  Downloading Cypress     [started]
 
[13:51:19]  Downloading Cypress     [failed]
 
The Cypress App could not be downloaded.
 

 
Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration
 

 
Otherwise, please check network connectivity and try again:
 

 
----------
 

 
URL: https://download.cypress.io/desktop/4.10.0?platform=linux&arch=x64
 
Error: Corrupted download
 

 
Expected downloaded file to have checksum: 9a556edc2730b89aa22ca5024acbaf734dd5560692e143ad4aab8fabea0ad4fd6ca8c4e34f0013e3d62de98aac744a5bb65469abc9f2b6b975c788e79ee18f73
 
Computed checksum: 63f9ce8b1db5613e441bbc5a05b2e0f2ab2ef95382621d85dc516c5d2878811353f7e0b9d9de47066e8cfa1bd8dbf4c8b3e9889d0835dc66f4af82473aa6f486
 

 
Expected downloaded file to have size: 188622855
 
Computed size: 188622855
 

 
----------
 

 
Platform: linux (Debian - 9.11)
 
Cypress Version: 4.10.0
 

 
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
 
 
Exited with code exit status 1 

CircleCI received exit code 1 

Possible related issues

@jennifer-shehane
Copy link
Member

Duplicate of #4595

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants