cypress icon indicating copy to clipboard operation
cypress copied to clipboard

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

Open jennifer-shehane opened this issue 6 years ago • 34 comments
trafficstars

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

jennifer-shehane avatar Dec 03 '18 08:12 jennifer-shehane

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

adamchenwei avatar Apr 02 '19 19:04 adamchenwei

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.

jennifer-shehane avatar Apr 18 '19 06:04 jennifer-shehane

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

adamchenwei avatar Apr 18 '19 13:04 adamchenwei

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.

ruvengam avatar Jul 24 '19 08:07 ruvengam

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

v-stickykeys avatar Sep 16 '19 15:09 v-stickykeys

+1 for this bug (ran into it also)

fingolfinor avatar Oct 01 '19 14:10 fingolfinor

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

ShakurOo avatar Dec 12 '19 16:12 ShakurOo

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)

JFRabbit avatar Dec 23 '19 09:12 JFRabbit

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

zhangyoufu avatar Apr 02 '20 10:04 zhangyoufu

This issue is on MacOS Catalina as well

josephzidell avatar Jun 05 '20 13:06 josephzidell

@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.

jennifer-shehane avatar Jun 09 '20 08:06 jennifer-shehane

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

imgruntw avatar Aug 06 '20 11:08 imgruntw

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

fndg87 avatar Nov 28 '20 15:11 fndg87

Is this error still occurring? We haven't had reports for some time.

jennifer-shehane avatar Aug 19 '21 12:08 jennifer-shehane

Yes I had this error today running a build in Jenkins on Windows Server 2016. Version 8.3.1 of Cypress

[Pipeline] bat
17:55:29  
17:55:29  C:\Users\Agtrader\AppData\Local\Jenkins.jenkins\workspace\Cypress via GitHub>npx cypress --version 
17:55:33  Cypress package version: 8.3.1
17:55:33  Cypress binary version: 8.3.1
17:55:33  Electron version: 13.2.0
17:55:33  Bundled Node version: 
17:55:33  14.16.0
[Pipeline] bat
17:55:33  
17:55:33  C:\Users\Agtrader\AppData\Local\Jenkins.jenkins\workspace\Cypress via GitHub>npx [email protected] run --reporter junit --reporter-options mochaFile=result.xml,toConsole=false --spec ".\cypress\integration\cefetra\navigation.spec.js"  --browser electron --config video=false 
18:00:10  
18:00:25  Warning: We failed to trash the existing run results.
18:00:25  
18:00:25  This error will not alter the exit code.
18:00:25  
18:00:25  Error: Command failed: C:\Users\Agtrader\AppData\Local\Cypress\Cache\8.3.1\Cypress\resources\app\packages\server\node_modules\trash\lib\win-trash.exe C:\Users\Agtrader\AppData\Local\Jenkins.jenkins\workspace\Cypress via GitHub\cypress\screenshots\cefetra
18:00:25  
18:00:25      at ChildProcess.exithandler (child_process.js:317:12)
18:00:25      at ChildProcess.emit (events.js:315:20)
18:00:25      at maybeClose (internal/child_process.js:1048:16)
18:00:25      at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) [Pipeline] bat
17:55:29  
17:55:29  C:\Users\Agtrader\AppData\Local\Jenkins.jenkins\workspace\Cypress via GitHub>npx cypress --version 
17:55:33  Cypress package version: 8.3.1
17:55:33  Cypress binary version: 8.3.1
17:55:33  Electron version: 13.2.0
17:55:33  Bundled Node version: 
17:55:33  14.16.0
[Pipeline] bat
17:55:33  
17:55:33  C:\Users\Agtrader\AppData\Local\Jenkins.jenkins\workspace\Cypress via GitHub>npx [email protected] run --reporter junit --reporter-options mochaFile=result.xml,toConsole=false --spec ".\cypress\integration\cefetra\navigation.spec.js"  --browser electron --config video=false 
18:00:10  
18:00:25  Warning: We failed to trash the existing run results.
18:00:25  
18:00:25  This error will not alter the exit code.
18:00:25  
18:00:25  Error: Command failed: C:\Users\Agtrader\AppData\Local\Cypress\Cache\8.3.1\Cypress\resources\app\packages\server\node_modules\trash\lib\win-trash.exe C:\Users\Agtrader\AppData\Local\Jenkins.jenkins\workspace\Cypress via GitHub\cypress\screenshots\cefetra
18:00:25  
18:00:25      at ChildProcess.exithandler (child_process.js:317:12)
18:00:25      at ChildProcess.emit (events.js:315:20)
18:00:25      at maybeClose (internal/child_process.js:1048:16)
18:00:25      at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)

miken-hg5 avatar Aug 31 '21 21:08 miken-hg5

We've been encountering it for about a month here as well. In addition cypress is failing to remove firefox instances. Logging for both issues:

build	13-Sep-2021 16:26:47	> [email protected] reportdev E:\bamboo\home\xml-data\build-dir\SFDC-SCME2ED1-JOB1\tests\e2e
build	13-Sep-2021 16:26:47	> npx cypress run --browser firefox --env configFile=dev || cd.
build	13-Sep-2021 16:26:47	
build	13-Sep-2021 16:26:56	
build	13-Sep-2021 16:27:48	Warning: We failed to trash the existing run results.
build	13-Sep-2021 16:27:48	
build	13-Sep-2021 16:27:48	This error will not alter the exit code.
build	13-Sep-2021 16:27:48	
build	13-Sep-2021 16:27:48	Error: Command failed: C:\Users\user\AppData\Local\Cypress\Cache\8.3.0\Cypress\resources\app\packages\server\node_modules\trash\lib\win-trash.exe E:\bamboo\home\xml-data\build-dir\SFDC-SCME2ED1-JOB1\tests\e2e\cypress\screenshots\NavLinksAndURLs.spec.ts
build	13-Sep-2021 16:27:48	
build	13-Sep-2021 16:27:48	    at ChildProcess.exithandler (child_process.js:317:12)
build	13-Sep-2021 16:27:48	    at ChildProcess.emit (events.js:315:20)
build	13-Sep-2021 16:27:48	    at maybeClose (internal/child_process.js:1048:16)
build	13-Sep-2021 16:27:48	    at Socket.<anonymous> (internal/child_process.js:439:11)
build	13-Sep-2021 16:27:48	    at Socket.emit (events.js:315:20)
build	13-Sep-2021 16:27:48	    at Pipe.<anonymous> (net.js:673:12)
build	13-Sep-2021 16:27:48	
build	13-Sep-2021 16:27:51	Warning: We failed to remove old browser profiles from previous runs.
build	13-Sep-2021 16:27:51	
build	13-Sep-2021 16:27:51	This error will not alter the exit code.
build	13-Sep-2021 16:27:51	
build	13-Sep-2021 16:27:51	Error: EBUSY: resource busy or locked, unlink 'C:\Users\user\AppData\Roaming\Cypress\cy\production\browsers\firefox-stable\run-3304\cookies.sqlite-shm'

HamboneWilson avatar Sep 14 '21 12:09 HamboneWilson

There's some suspicion that this error may occur if you are running Cypress processes in parallel on the same machine. One Cypress process may be accessing or writing to the videos folder while the other process is attempting to delete the videos folder.

We do not recommend running multiple Cypress processes in parallel on the same machine. Cypress should be run in parallel machines.

Can anyone confirm if this is or is not how they are running their tests?

jennifer-shehane avatar Oct 11 '21 20:10 jennifer-shehane

Have a single cypress process in my machine but issue still occurs.

I am trying to trigger execution from local machine to cy dashboard., this is a single process as I have closed the test runner. Also, I have closed all preview applications. But the issue occurs

$ npx cypress run --record --key <key> --spec "cypress/integration/specs/ShowMapLayers.feature"  --ci-build-id "test1" --group="google-chrome"

The run you are attempting to access is already complete and will not accept new groups.

The existing run is: https://dashboard.cypress.io/projects/<pid>/runs

When a run finishes all of its groups, it waits for a configurable set of time before finally completing. You must add more groups during that time period.

The --tag flag you passed was: 
The --group flag you passed was: google-chrome
The --ciBuildId flag you passed was: test1

https://on.cypress.io/already-complete

The existing run is: https://dashboard.cypress.io/projects/projectNum/runs - This has nothing as the trigger did not happen at all.

dhamo-pk avatar Nov 02 '21 09:11 dhamo-pk

I'm also having this happen on MacOS. If my videos folder is open, any files with thumbnails currently visible (icons are on and large) causes this error to throw at the beginning of each run for me.

astraljames avatar Nov 29 '21 21:11 astraljames

I'm seeing something like this when having screenshotsFolder, videosFolder, and the cypress-terminal-report plugin to the same directory. Perhaps Cypress and the cypress-terminal-report plugin are both trying to remove the directory?

cypress.json:

{
  ...
  "screenshotsFolder": "./cypress/results",
  "videosFolder": "./cypress/results",
  ...
}

Plugin config:

  installLogsPrinter(on, {
    // https://github.com/archfz/cypress-terminal-report#options-for-the-plugin-install
    includeSuccessfulHookLogs: false,
    outputRoot: 'cypress/results/',
    outputTarget: {
      // format is: '<targetdir>|<extension>': 'txt|json'
      // cypress/integration/subdir/filename.test.ts -> cypress/results/<targetdir>/subdir/filename.test.<extension>
      '.|log': 'txt',
    },
    outputVerbose: false,
    specRoot: 'cypress/integration',
  });

DanaGoyette avatar Dec 14 '21 02:12 DanaGoyette

There's some suspicion that this error may occur if you are running Cypress processes in parallel on the same machine. One Cypress process may be accessing or writing to the videos folder while the other process is attempting to delete the videos folder.

We do not recommend running multiple Cypress processes in parallel on the same machine. Cypress should be run in parallel machines.

Can anyone confirm if this is or is not how they are running their tests?

Yes. I am trying to run Cypress in parallel on the same machine and it's doing this exact thing. From what I can gather, the first process tries to delete my screenshots/downloads folder and then the other processes try to do the same but can't find it and log the error.

It's strange though because if I manually start each process in a different CLI I don't get the error. If they are child processes that are created from my script, then the error occurs. It's quite strange and I'm not sure why it doesn't occur when I manually start them.

Terranon avatar Feb 22 '22 19:02 Terranon

Um, did we solve this issue or no? :)

stephyswe avatar Sep 23 '22 07:09 stephyswe

Still exist in 9.7.0: image

Onnaien avatar Sep 30 '22 14:09 Onnaien

Still exists in 10.9.0

jaxfellow avatar Oct 07 '22 09:10 jaxfellow

For me this was related to a del update to 7.0.0 which has a breaking switch to pure ESM. Downgrading to [email protected] fixed it for me on [email protected].

walter-r-m avatar Nov 11 '22 15:11 walter-r-m

Still exists in 11.2.0, is there any updates?

dylannnn avatar Dec 01 '22 14:12 dylannnn

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

chown :staff macos-trash

Browse to the directory (adapt your own path)

cd /Users/xxx/Library/Caches/Cypress/12.4.0/Cypress.app/Contents/Resources/app/node_modules/trash/lib

Keep a copy for the original

cp macos-trash macos-trash-original cp ~/Downloads/macos-trash .

The file was already mark as executable If needed :

chmod +x macos-trash

Now, no more error, the directory is cleaned normally.

Best

John

johndegey avatar Jan 26 '23 10:01 johndegey

It happens because the screenshot has nested folders The following commands help me:

PowerShell

give write access to the folder:

icacls "cypress\cypress\screenshots\FOLDER_NAME" /grant:r "$env:USERNAME`:F" /T

Remove the read-only attribute (-R), removes the archive attribute (-A) to the folder

attrib -R -A "cypress\cypress\screenshots\FOLDER_NAME"

change FOLDER_NAME to your folders name

or for multiple nested folders:

Get-ChildItem -Path "cypress\cypress\screenshots" -Directory -Recurse | foreach { attrib -R -A "$($_.FullName)\*" /S }
Get-ChildItem -Path "cypress\cypress\screenshots" -Directory -Recurse | foreach { icacls $_.FullName /grant:r "$env:USERNAME`:F" /T }

Jarroslav avatar Apr 14 '23 09:04 Jarroslav

Still there ..

image

rzfrsn avatar Apr 25 '23 20:04 rzfrsn

Seeing this error as well when running locally on M2 MacBook Pro with Ventura. Using Cypress 12.13.0.


This error will not affect or change the exit code.

Error: spawn Unknown system error -86
    at ChildProcess.spawn (node:internal/child_process:413:11)
    at spawn (node:child_process:709:9)
    at execFile (node:child_process:336:17)
    at node:child_process:243:21
    at node:electron/js2c/asar_bundle:5:3131
    at s.exports (<embedded>:3174:1128678)
    at <embedded>:3174:1136681
    at <embedded>:3139:423894
    at new Promise (<anonymous>)
    at r (<embedded>:3139:423875)
    at p (<embedded>:3174:1136189)
    at <embedded>:4696:491874
    at tryCatcher (/Users/leadoux/Library/Caches/Cypress/12.13.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23)
    at MappingPromiseArray._promiseFulfilled (/Users/leadoux/Library/Caches/Cypress/12.13.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/map.js:61:38)
    at MappingPromiseArray.<anonymous> (/Users/leadoux/Library/Caches/Cypress/12.13.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise_array.js:114:31)
    at MappingPromiseArray.init (/Users/leadoux/Library/Caches/Cypress/12.13.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise_array.js:78:10)
    at Promise._settlePromise (/Users/leadoux/Library/Caches/Cypress/12.13.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:566:21)
    at Promise._settlePromise0 (/Users/leadoux/Library/Caches/Cypress/12.13.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/leadoux/Library/Caches/Cypress/12.13.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:694:18)
    at Promise._fulfill (/Users/leadoux/Library/Caches/Cypress/12.13.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/promise.js:638:18)
    at /Users/leadoux/Library/Caches/Cypress/12.13.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/nodeback.js:42:21
    at <embedded>:1969:98429
    at <embedded>:4703:19668
    at FSReqCallback.oncomplete (node:fs:188:23)

leadoux avatar May 28 '23 22:05 leadoux