cypress: On cypress run, error "We failed to trash the existing run results"
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
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 22
- Comments: 35 (7 by maintainers)
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
Still there …
Still exists in 10.9.0
thanks @ruvengam . My solution was, delete the video and screenshot files then cypress run again. It works.
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:
Encountered the same issue on version 3.4.0 on windows 10 OS, When using
npx cypress rungot this error:This error followed by additional error message at one specific test:
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 videowithPermission 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.
When I specify
"screenshotsFolder": falseincypress.json, this error also occurs.It happens because the screenshot has nested folders The following commands help me:
PowerShell
give write access to the folder:
Remove the read-only attribute (-R), removes the archive attribute (-A) to the folder
change FOLDER_NAME to your folders name
or for multiple nested folders:
Hello,
Still exists in 12.4.0. So I manage to update macos-trash directly in the cypress.app package.
Download the binary from https://github.com/sindresorhus/macos-trash Extract it and rename from trash to macos-trash
Need to chown (setting the right group) : open a terminal and change to your download directory
Browse to the directory (adapt your own path)
Keep a copy for the original
The file was already mark as executable If needed :
Now, no more error, the directory is cleaned normally.
Best
John
same issue with Windows 10 and Cypress 4.10.0