Skip to content

Commit 82600d2

Browse files
authored
Merge branch 'master' into add/chrome-for-testing
2 parents b1856b2 + c07fb74 commit 82600d2

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,34 @@ container:
157157
158158
See [Tag Selection](#tag-selection) above for advice on selecting a non-default image tag.
159159
160+
## EACCES permission denied binary_state.json
161+
162+
### Problem
163+
164+
If a custom Docker image is built from a `cypress/base` or `cypress/browsers` Cypress Docker image, using a `Dockerfile` to install the Cypress binary (for instance with `npx cypress install`), and the custom image is then run as a container with a non-root user, Cypress will fail to run with an error message:
165+
166+
> Error: EACCES: permission denied, open '/root/.cache/Cypress/`<Cypress version>`/binary_state.json'
167+
168+
This is due to an open Cypress issue [#30684](https://github.com/cypress-io/cypress/issues/30684) where Cypress fails to verify the installed Cypress binary if it does not have write access to the Cypress binary directory.
169+
170+
### Workaround
171+
172+
To workaround this issue, either make the Cypress binary directory writable, or skip the Cypress binary verification.
173+
174+
To make the complete Cypress binary directory writable, add the following to the `Dockerfile` after the step to install the Cypress binary:
175+
176+
```Dockerfile
177+
RUN chmod -R 777 /root/.cache/Cypress
178+
```
179+
180+
To skip Cypress binary verification using the environment variable `CYPRESS_SKIP_VERIFY`, described in the Cypress documentation [Advanced Installation](https://docs.cypress.io/app/references/advanced-installation#Environment-variables), either add the following to the `Dockerfile`:
181+
182+
```Dockerfile
183+
ENV CYPRESS_SKIP_VERIFY=true
184+
```
185+
186+
or pass the environment variable as an additional CLI option `--env CYPRESS_SKIP_VERIFY=true` to the [docker run](https://docs.docker.com/reference/cli/docker/container/run/) command.
187+
160188
## Contributing
161189

162190
See [CONTRIBUTING.md](CONTRIBUTING.md)

examples/included-as-non-root/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,20 @@ docker run --rm -v .:/test -w /test -u node cypress/included
3333
```
3434

3535
You can expect this command to run successfully.
36+
37+
## GitHub Actions
38+
39+
In general when running Cypress Docker images in GitHub Actions it is recommended to use the GitHub Actions' `container` syntax (see [Running jobs in a container](https://docs.github.com/en/actions/writing-workflows/choosing-where-your-workflow-runs/running-jobs-in-a-container) and [.github/workflows/example-cypress-github-action.yml](../../.github/workflows/example-cypress-github-action.yml)).
40+
41+
If however Docker is run directly in a GitHub Actions workflow, such as:
42+
43+
```yaml
44+
- run: docker run --rm -v .:/test -w /test -u node cypress/included
45+
working-directory: examples/included-as-non-root
46+
```
47+
48+
then the `docker` command will be run from GitHub's `runner` user `1001` and the Cypress Docker image `node` user `1000` will have no write access to the `/test` directory. Cypress will warn that the project root directory is read-only and that screenshots and videos cannot be captured.
49+
50+
To enable screenshot and video captures, redirect the folders to a writable folder, such as `/tmp`. See [cypress.config.js](./cypress.config.js) for an example.
51+
52+
Pending resolution of Cypress issue https://github.com/cypress-io/cypress/issues/30810, Cypress will however still produce a warning.
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
const { defineConfig } = require('cypress')
1+
const { defineConfig } = require('cypress');
22

33
module.exports = defineConfig({
4+
downloadsFolder: '/tmp/cypress/downloads',
5+
screenshotsFolder: '/tmp/cypress/screenshots',
6+
videosFolder: '/tmp/cypress/videos',
47
fixturesFolder: false,
58
e2e: {
69
supportFile: false,
710
},
8-
})
11+
});

examples/included-as-non-root/cypress/e2e/spec.cy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ describe('test local demo page', () => {
22
it('heading', () => {
33
cy.visit('index.html')
44
cy.contains('h2', 'Test')
5+
cy.screenshot()
56
})
67
})

0 commit comments

Comments
 (0)