cypress: Cypress cannot delete profileDir on exit because it creates files with only read permissions.

Current behavior

Whenever I run tests on a specific browser, I get the linked error when stopping the process.

So pretty clear, it just has no permission to delete some files it created earlier. So I have to do it manually then it works again.

The problem is that even if I change manually the permissions of the entire folder, cypress creates files with only read permission:

~/.config/Cypress/cy/production/browsers/firefox-stable/interactive/CypressExtension Image

So later, it’s unable to delete them.

I’m not sure what I can do to change this behavior. Also I’m wondering why putting these files into .config when it’s seems like cache files to me?

Is this problem linked to the fact that I use CYPRESS_RUN_BINARY?

Thanks in advance for any input.

Desired behavior

Cypress should create files with delete permission to be able later to delete them.

Test code to reproduce

Nothing special except I use CYPRESS_RUN_BINARY that runs a binary from nix.

Cypress Version

13.17.0

Node version

v20.18.3

Operating System

nix (Nix) 2.24.12

Debug Logs

[firefox-profile] cannot delete profileDir on exit /home/jed/.config/Cypress/cy/production/browsers/firefox-stable/interactive Error: EACCES: permission denied, unlink '/home/jed/.config/Cypress/cy/production/browsers/firefox-stable/interactive/CypressExtension/background.js'
    at unlinkSync (node:fs:1883:3)
    at _unlinkSync (node:internal/fs/rimraf:214:14)
    at rimrafSync (node:internal/fs/rimraf:195:7)
    at node:internal/fs/rimraf:253:9
    at Array.forEach (<anonymous>)
    at _rmdirSync (node:internal/fs/rimraf:250:7)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at node:internal/fs/rimraf:253:9
    at Array.forEach (<anonymous>)
    at _rmdirSync (node:internal/fs/rimraf:250:7)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at Object.rmSync (node:fs:1278:10)
    at v._cleanOnExit (<embedded>:777:119095)
    at process.onExit (<embedded>:777:117974)
    at process.emit (node:events:526:35)
    at App.<anonymous> (node:electron/js2c/browser_init:2:119065)
    at App.emit (node:events:514:28)
    at Immediate.<anonymous> (<embedded>:3024:99555)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  errno: -13,
  syscall: 'unlink',
  code: 'EACCES',
  path: '/home/jed/.config/Cypress/cy/production/browsers/firefox-stable/interactive/CypressExtension/background.js'
}

Other

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 16 (11 by maintainers)

Most upvoted comments

@AtofStryker

The beta binary doesn’t resolve the issue unfortunately. Perhaps it is a timing issue since in some runs there was no issue, and then in others it failed to delete the profile on exit.

These are my steps:

git clone --branch firefox-profile https://github.com/MikeMcC399/cypress-test-tiny
cd cypress-test-tiny
npm ci
./firefox-loop.sh # fails sporadically
npm install npm install https://cdn.cypress.io/beta/npm/14.2.1/win32-x64/chore/FF-investigation-6286411864a452664012a221430bc3af8e10e0f4/cypress.tgz
./firefox-loop.sh

with logs attached:

firefox-cypress-31300.log

  • New issue is #31324 for Windows.

Windows is showing the following, which is a different errno from the one in this issue (errno: -13)

  errno: -4048,
  code: 'EPERM',
  syscall: 'unlink',

@ValJed Could you try updating to latest in Firefox and see if this issue still persists? We made a lot of changes to how we interact with Firefox in 14.1.0 and I just want to see if this may already be fixed. Thanks!