Cypress: On cypress run, error "We failed to trash the existing run results"

Created on 3 Dec 2018  Â·  13Comments  Â·  Source: cypress-io/cypress

Current behavior:

Running cypress run emits an error:

Warning: We failed to trash the existing run results.

This error will not alter the exit code.

Error: Command failed: /Users/jennifer/Library/Caches/Cypress/3.1.2/Cypress.app/Contents/Resources/app/packages/server/node_modules/trash/lib/macos-trash /Users/jennifer/Dev/cypress-example-kitchensink/cypress/screenshots/examples
“examples” couldn’t be moved to the trash.

    at ChildProcess.exithandler (child_process.js:282:12)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:921:16)
    at Socket.stream.socket.on (internal/child_process.js:348:11)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at Pipe._handle.close [as _onclose] (net.js:549:12)

Desired behavior:

Not error when trashing folders within videos folder.

Steps to reproduce:

All I did was cypress run on a previous run cypress-example-kitchensink project. Of course on subsequent runs of of cypress run do not produce the same error. 😞

Versions

Cypress 3.1.2
Mac High Sierra

needs investigating snapshot bug

Most helpful comment

It seems the problem only happens when a snapshot is open by an application somewhere else while cypress is trying to clean the directory, so it can't. At least that's seems how I fixed it, by closing the app that still viewing the snapshot images.

Hope it helps

All 13 comments

having same problem.... latest cypress and imagesnapshot, why cypress is getting so buggie lol

Any help on how to exactly reproduce this error every time would be appreciated, as I only experienced this once and was not able to reproduce.

It seems the problem only happens when a snapshot is open by an application somewhere else while cypress is trying to clean the directory, so it can't. At least that's seems how I fixed it, by closing the app that still viewing the snapshot images.

Hope it helps

Encountered the same issue on version 3.4.0 on windows 10 OS,
When using npx cypress run got this error:

Warning: We failed to trash the existing run results.

This error will not alter the exit code.

Error: Command failed: C:\Users\reuve-ga\AppData\Local\Cypress\Cache\3.4.0\Cypress\resources\app\packages\server\node_modules\trash\lib\win-trash.exe C:\cypress\videos\

    at ChildProcess.exithandler (child_process.js:287:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

This error followed by additional error message at one specific test:

Warning: We failed to record the video.

This error will not alter the exit code.

Error: ffmpeg exited with code 1: C:\cypress\videos\some-test\test-video.mp4: Permission denied

    at ChildProcess.<anonymous> (C:\Users\reuve-ga\AppData\Local\Cypress\Cache\3.4.0\Cypress\resources\app\packages\server\node_modules\fluent-ffmpeg\lib\processor.js:182:22)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)

{ Error: ffmpeg exited with code 1: C:\cypress\videos\some-test\test-video.mp4: Permission denied

    at ChildProcess.<anonymous> (C:\Users\reuve-ga\AppData\Local\Cypress\Cache\3.4.0\Cypress\resources\app\packages\server\node_modules\fluent-ffmpeg\lib\processor.js:182:22)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
 recordingVideoFailed: true }
Error: ffmpeg exited with code 1: C:\cypress\videos\some-test\test-video.mp4: Permission denied

    at ChildProcess.<anonymous> (C:\Users\reuve-ga\AppData\Local\Cypress\Cache\3.4.0\Cypress\resources\app\packages\server\node_modules\fluent-ffmpeg\lib\processor.js:182:22)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)

Reading the permission denied comment in the error message I ran Cypress with admin privileges,
This didn't help to resolve the issue.
Only then I started looking for the same issue in Cypress github project, found this issue,
as @adamchenwei mentioned I found that the video specified in the second warning is open in a media player app.

It looks like Cypress failed to trash the video folder since it was in use by the media player,
So it issued the first warning: Warning: We failed to trash the existing run results.

Then when cypress tried to override the video opened in the media player it got the We failed to record the video with Permission denied.

This don`t look like a bug, this is the OS preventing modification of an open file.
But Cypress warning message can suggest looking for the specified file in open programs.

thanks @ruvengam . My solution was, delete the video and screenshot files then cypress run again. It works.

+1 for this bug (ran into it also)

Could we shut down this warning with a flag ? --silent or --quiet maybe ?

reproduce this issue after update cypress from 3.7.0 to 3.8.0:

jasonzhang@bogon cypress-demo % node run.js 
Warning: We failed to trash the existing run results.

This error will not alter the exit code.

Error: Command failed: /Users/jasonzhang/Library/Caches/Cypress/3.8.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/trash/lib/macos-trash /Users/jasonzhang/Documents/code/cypress-demo/cypress/screenshots/sdlg
“sdlg” couldn’t be moved to the trash.

    at ChildProcess.exithandler (child_process.js:308:12)
    at ChildProcess.emit (events.js:203:13)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)

When I specify "screenshotsFolder": false in cypress.json, this error also occurs.

This issue is on MacOS Catalina as well

@ruvengam Yeah, I'm not able to replicate this while having the previously recorded video or screenshots open in my OS, but there may be something to this idea.

same issue with Windows 10 and Cypress 4.10.0

Warning: We failed to trash the existing run results.

This error will not alter the exit code.

Error: Command failed: C:\Users\user\AppData\Local\Cypress\Cache\4.10.0\Cypress\resources\app\packages\server\node_modules\trash\lib\win-trash.exe C:\dev\cypress\media\tests.ts.mp4

Noticed for some reason the videos and screenshots folders were owned by root (MacOs).

I was able to workaround this by changing the ownership of the folders:

sudo chown -R $(whoami) cypress/videos
sudo chown -R $(whoami) cypress/screenshots

Was this page helpful?
0 / 5 - 0 ratings