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

Cypress fails verification if directory for binary_state.json is read-only #30684

Open
MikeMcC399 opened this issue Nov 27, 2024 · 1 comment

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Nov 27, 2024

Current behavior

Cypress fails to run if the directory one level above the binaryDir of CYPRESS_RUN_BINARY as shown in the debug logs (see Run binary) is read-only. The error message is similar to:

Error: EACCES: permission denied, open '/home/mike/.cache/Cypress/13.16.0/binary_state.json'

If the Cypress binary was verified before the directory was set to read-only, then the error message is similar to:

Error: EACCES: permission denied, unlink '/home/mike/.cache/Cypress/13.16.0/binary_state.json'

Desired behavior

Cypress should be tolerant of a read-only Cypress binary location CYPRESS_RUN_BINARY directory structure. Verification should take place successfully and Cypress should run.

Test code to reproduce

git clone https://github.com/cypress-io/github-action
cd github-action
git checkout 01447edc92a4a18ac78edf5b7d1b8fc54be4e5dd
cd examples/basic
npm ci
stat ~/.cache/Cypress/13.16.0
chmod =0555 ~/.cache/Cypress/13.16.0 # make read-only
CYPRESS_RUN_BINARY=~/.cache/Cypress/13.16.0/Cypress/Cypress npx cypress verify # this fails
chmod =0775 ~/.cache/Cypress/13.16.0 # restore original permissions
CYPRESS_RUN_BINARY=~/.cache/Cypress/13.16.0/Cypress/Cypress npx cypress verify # this succeeds

Note that pointing CYPRESS_RUN_BINARY to the binary cache is only done here for convenience of reproduction steps. Normally you would separately download the Cypress binary (https://docs.cypress.io/app/references/advanced-installation#Download-URLs), unzip it, then set the CYPRESS_RUN_BINARY to point to a location as shown in the documentation (https://docs.cypress.io/app/references/advanced-installation#Run-binary).

Cypress Version

13.16.0

Node version

v22.11.0 LTS

Operating System

Ubuntu 24.04.1 LTS

Debug Logs

$ CYPRESS_RUN_BINARY=~/.cache/Cypress/13.16.0/Cypress/Cypress npx cypress verify
  cypress:cli:cli cli starts with arguments ["/home/mike/n/bin/node","/home/mike/github/cypress-io/cypress-test-tiny/node_modules/.bin/cypress","verify"] +0ms
  cypress:cli NODE_OPTIONS is not set +0ms
  cypress:cli:cli program parsing arguments +0ms
  cypress:cli parsed cli options {} +1ms
  cypress:cli verifying Cypress app +0ms
  cypress:cli checking environment variables +1ms
  cypress:cli Using CYPRESS_RUN_BINARY from environment variable +81ms
  cypress:cli Using CYPRESS_RUN_BINARY from environment variable +0ms
  cypress:cli CYPRESS_RUN_BINARY exists, = /home/mike/.cache/Cypress/13.16.0/Cypress/Cypress +0ms
  cypress:cli CYPRESS_RUN_BINARY is executable? : true +3ms
  cypress:cli CYPRESS_RUN_BINARY has realpath: /home/mike/.cache/Cypress/13.16.0/Cypress/Cypress +0ms
  cypress:cli CYPRESS_RUN_BINARY has binaryDir: /home/mike/.cache/Cypress/13.16.0/Cypress +14ms
  cypress:cli checking if executable exists /home/mike/.cache/Cypress/13.16.0/Cypress/Cypress +0ms
  cypress:cli Binary is executable? : true +0ms
  cypress:cli binaryDir is  /home/mike/.cache/Cypress/13.16.0/Cypress +1ms
  cypress:cli Reading binary package.json from: /home/mike/.cache/Cypress/13.16.0/Cypress/resources/app/package.json +1ms
  cypress:cli Found binary version 13.16.0 installed in: /home/mike/.cache/Cypress/13.16.0/Cypress +1ms
  cypress:cli could not read binary_state.json file at "/home/mike/.cache/Cypress/13.16.0/binary_state.json" +1ms
  cypress:cli {} +0ms
  cypress:cli is Verified ? undefined +0ms
  cypress:cli force verify +0ms
  cypress:cli running binary verification check 13.16.0 +0ms

  cypress:cli clearing out the verified version +7ms
  cypress:cli DISPLAY environment variable is set to :0 on Linux
  cypress:cli Assuming this DISPLAY points at working X11 server,
  cypress:cli Cypress will not spawn own Xvfb
  cypress:cli
  cypress:cli NOTE: if the X11 server is NOT working, Cypress will exit without explanation,
  cypress:cli   see https://github.com/cypress-io/cypress/issues/4034
  cypress:cli Solution: Unset the DISPLAY variable and try again:
  cypress:cli   DISPLAY= npx cypress run ... +0ms
  cypress:cli needs Xvfb? false +1ms
  cypress:cli spawning, should retry on display problem? true +0ms
  cypress:cli disabling Electron sandbox +0ms
  cypress:cli running smoke test +0ms
  cypress:cli using Cypress executable /home/mike/.cache/Cypress/13.16.0/Cypress/Cypress +1ms
  cypress:cli smoke test command: /home/mike/.cache/Cypress/13.16.0/Cypress/Cypress --no-sandbox --smoke-test --ping=423 +0ms
  cypress:cli smoke test timeout 30000 ms +0ms
  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
423" +1s
  cypress:cli write verified: true +393ms

  cypress:cli detecting arch { osPlatform: 'linux', osArch: 'x64' } +2s
  cypress:cli arm uname -m result: { stdout: 'x86_64' }  +3ms
An unexpected error occurred while verifying the Cypress executable.

Please search Cypress documentation for possible solutions:

https://on.cypress.io

Check if there is a GitHub issue describing this crash:

https://github.com/cypress-io/cypress/issues

Consider opening a new issue.

----------

Error: EACCES: permission denied, open '/home/mike/.cache/Cypress/13.16.0/binary_state.json'

----------

Platform: linux-x64 (Ubuntu - 24.04)
Cypress Version: 13.16.0

Other

Workaround

Set the environment variable:

CYPRESS_SKIP_VERIFY=true

See https://docs.cypress.io/app/references/advanced-installation#Environment-variables

@MikeMcC399
Copy link
Contributor Author

MikeMcC399 commented Dec 2, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants