feat: add explicit cypress install step after dependency install#1799
feat: add explicit cypress install step after dependency install#1799mschile wants to merge 3 commits into
Conversation
Package managers may no longer run a dependency's postinstall script by default (pnpm and Yarn Berry already block them, npm 12 will via RFC #868). Cypress downloads its binary via postinstall, so on a cold cache the binary was not downloaded and `cypress verify` failed. Run a package-manager-aware `cypress install` after dependencies are installed (npx/yarn/pnpm), keeping the binary available regardless of package manager. The step is a no-op when the binary is already present and is skipped when CYPRESS_INSTALL_BINARY=0. Closes #1798 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`pnpm cypress install` fails to resolve the cypress binary inside pnpm workspace packages (ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL). Match the existing `cypress verify` / `cypress cache list` steps, which invoke cypress via npx for every package manager, so the binary resolves consistently in pnpm and Yarn workspaces. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
MikeMcC399
left a comment
There was a problem hiding this comment.
I'm skeptical about combining npm's npx with Yarn and pnpm package managers. It has led to errors in the past.
The repo has been patched multiple times since the origin npm / Yarn Classic implementation to incorporate the later Yarn Modern and pnpm, and by now it's a bit difficult to maintain any further changes.
This PR should in any case be tested against a Cypress version that it not cypress@latest. npx will pull the latest version if it's not already installed.
I'm also not sure if this PR is necessary at this time.
In general, users will have set up their projects to install and test locally as a first step and they will have needed to add whatever configuration parameters are necessary to allow Cypress to install together with the Cypress binary. When they commit this configuration to a GitHub repo, it will also run there and allow the Cypress binary install.
If this weren't the case we would have already seen user issues reported for pnpm, and there haven't been any.
In terms of this repo, I would advocate minimum necessary changes to keep things running. Yarn Modern isn't properly supported anyway. Same for pnpm workspaces. Yarn v6 is on the horizon as well, with significant changes planned.
|
Running pnpm@11 standalone without allowBuilds:
cypress: trueor allowBuilds:
cypress: falseattempting to run the following otherwise fails: pnpm cypress install |
|
At this time I would want to withhold support for this PR. A correctly configured Changes affecting other package managers may introduce additional problems. I'd suggest waiting for the release of npm@12, and a decision about whether it will be bundled into Node.js 26. The documentation on https://docs.cypress.io/app/get-started/install-cypress#npm-configuration is inaccurate, about how to modify If Cypress.io decides to move away from |
|
What
Adds an explicit
cypress installstep that runs after dependency install inindex.js, invoked vianpxfor all package managers:The step runs on every install path (including a custom
install-command), is skipped wheninstall: false, and respectsCYPRESS_INSTALL_BINARY=0. It's a no-op when the binary is already present.Why
Package managers may no longer run a dependency's
postinstallscript by default — pnpm and Yarn Berry (≥4.14) already block them, and npm 12 will via RFC #868. Cypress downloads its binary via apostinstallscript, so without an explicit install:~/.cache/Cypress, unaffected.cypress verifyfails.Running
cypress installexplicitly downloads the binary on a cold cache regardless of package manager.Why
npxfor all package managers (notpnpm cypress/yarn cypress)The first iteration used package-manager-specific commands (
pnpm cypress install,yarn cypress install). That broke the pnpm-workspaces example with:Root cause:
pnpm <command>resolves<command>relative to the current directory's package. The action installs dependencies in the pnpm workspace root, whosepackage.jsondeclares nocypressdependency and nocypressscript (cypress is a devDependency of the child packages only). pnpm therefore has nocypresscommand to run there and errors out.npx cypressinstead resolves cypress from the dependency tree and finds the workspace's pinned version (verified:npx --no-install cypress --versionreturns the locked15.17.0from the workspace root, no download). This also matches how the action's existingcypress verifyandcypress cache liststeps already invoke cypress, so behavior is consistent across all three.Notes for reviewers
installMaybe()betweeninstall()andlistCypressBinaries().core.exportVariable('CYPRESS_CACHE_FOLDER', ...)in the new function —install()always runs immediately before it and already exports it for the process.dist/index.jsrebuilt via the pre-commit hook (ncc build).pnpm cypressissue).Closes #1798
References
🤖 Generated with Claude Code