actions / checkout

Action for checking out a repo
https://github.com/features/actions
MIT License
5.92k stars 1.75k forks source link

checkout@v3 failed on windows2022 self-hosted runner, reporting Error: File was unable to be removed Error: EBUSY: resource busy or locked #1230

Open jun2zhou opened 1 year ago

jun2zhou commented 1 year ago

checkout@v3 reporting below error on my windows2022 self-hosted runner, but checkout@v2 works ok!

C:\actions-runner\windows2022-003_work_actions\actions\checkout\v3\dist\index.js:6844 throw new Error(File was unable to be removed ${err}); ^

Error: File was unable to be removed Error: EBUSY: resource busy or locked, rmdir 'C:\actions-runner\windows2022-003_work_temp\dcd7fd89-dafd-4a46-b292-3c1c71a82794' at Object. (C:\actions-runner\windows2022-003_work_actions\actions\checkout\v3\dist\index.js:6844:19) at Generator.throw () at rejected (C:\actions-runner\windows2022-003_work_actions\actions\checkout\v3\dist\index.js:6738:65)

jww3 commented 1 year ago

It's possible this will get fixed by https://github.com/actions/toolkit/pull/1373 I'll check with the authors.

cory-miller commented 1 year ago

Some background:

On Windows we found that actions/checkout did not respect the Windows FileShare settings previously. So after https://github.com/actions/toolkit/pull/1373 it's possible to get this error if you have an open file and try to delete it. From researching the linked PR, that seemed like normal Windows behavior hence the change. This was not back-ported into actions/checkout@v2 since that has Node 12 support and Node only introduced its rm -rf feature in Node 14. You can also use actions/checkout@v3.3.0 to remain unblocked.

Can you tell us more about the file and your workflow or show us logs from a run? I would want to know what holds open the lock and how the file was opened. This way we can make sure that this gets closed before deleting the repository or we have additional logic to handle this.

jun2zhou commented 1 year ago

Run actions/checkout@main Syncing repository: chipsec/chipsec Getting Git version info Copying 'C:\Users\Administrator.gitconfig' to 'C:\actions-runner\windows2022-003_work_temp\5d9f2d3d-6f40-481b-89c0-1e89b725b6e2.gitconfig' Temporarily overriding HOME='C:\actions-runner\windows2022-003_work_temp\5d9f2d3d-6f40-481b-89c0-1e89b725b6e2' before making global git config changes Adding repository directory to the temporary git global config as a safe directory "C:\Program Files\Git\cmd\git.exe" config --global --add safe.directory C:\actions-runner\windows2022-003_work\frameworks.platforms.security.chipsec.chipsec-internal\frameworks.platforms.security.chipsec.chipsec-internal "C:\Program Files\Git\cmd\git.exe" config --local --get remote.origin.url https://github.com/chipsec/chipsec Removing previously created refs, to avoid conflicts Cleaning the repository "C:\Program Files\Git\cmd\git.exe" clean -ffdx "C:\Program Files\Git\cmd\git.exe" reset --hard HEAD HEAD is now at 505170a Updated PCIID database Disabling automatic garbage collection Setting up auth Determining the default branch Fetching the repository Determining the checkout info Checking out the ref "C:\Program Files\Git\cmd\git.exe" log -1 --format='%H' '505170aed7b222cb8c1094f977979cbea8d749f5' C:\actions-runner\windows2022-003_work_actions\actions\checkout\main\dist\index.js:6844 throw new Error(File was unable to be removed ${err}); ^

Error: File was unable to be removed Error: EBUSY: resource busy or locked, rmdir 'C:\actions-runner\windows2022-003_work_temp\5d9f2d3d-6f40-481b-89c0-1e89b725b6e2' at Object. (C:\actions-runner\windows2022-003_work_actions\actions\checkout\main\dist\index.js:6844:19) at Generator.throw () at rejected (C:\actions-runner\windows2022-003_work_actions\actions\checkout\main\dist\index.js:6738:65)

image
jun2zhou commented 1 year ago

tested actions/checkout/v3.3.0, occur below error: Self_Hosted_Windows Update self_hosted_windows.yml #177 Jobs Run details build (3.6) failed 1 minute ago in 19s Search logs 4s 9s Run actions/checkout@v3.3.0 Syncing repository: chipsec/chipsec Getting Git version info Copying 'C:\Users\Administrator.gitconfig' to 'C:\actions-runner\windows2022-003_work_temp\8277cb46-10f5-4bb2-9f34-88a178dc6eca.gitconfig' Temporarily overriding HOME='C:\actions-runner\windows2022-003_work_temp\8277cb46-10f5-4bb2-9f34-88a178dc6eca' before making global git config changes Adding repository directory to the temporary git global config as a safe directory "C:\Program Files\Git\cmd\git.exe" config --global --add safe.directory C:\actions-runner\windows2022-003_work\frameworks.platforms.security.chipsec.chipsec-internal\frameworks.platforms.security.chipsec.chipsec-internal "C:\Program Files\Git\cmd\git.exe" config --local --get remote.origin.url https://github.com/intel-restricted/frameworks.platforms.security.chipsec.chipsec-internal Deleting the contents of 'C:\actions-runner\windows2022-003_work\frameworks.platforms.security.chipsec.chipsec-internal\frameworks.platforms.security.chipsec.chipsec-internal' Initializing the repository Disabling automatic garbage collection Setting up auth Determining the default branch Fetching the repository Determining the checkout info Checking out the ref "C:\Program Files\Git\cmd\git.exe" log -1 --format='%H' '505170aed7b222cb8c1094f977979cbea8d749f5' node:internal/errors:841 const err = new Error(message); ^

Error: Command failed: C:\Windows\system32\cmd.exe /s /c "rd /s /q "%inputPath%"" The process cannot access the file because it is being used by another process.

at ChildProcess.exithandler (node:child_process:398:[1](https://github.com/intel-restricted/frameworks.platforms.security.chipsec.chipsec-internal/actions/runs/4465029569/jobs/7841709326#step:2:1)2)
at ChildProcess.emit (node:events:527:[28](https://github.com/intel-restricted/frameworks.platforms.security.chipsec.chipsec-internal/actions/runs/4465029569/jobs/7841709326#step:2:31))
at maybeClose (node:internal/child_process:1092:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:[30](https://github.com/intel-restricted/frameworks.platforms.security.chipsec.chipsec-internal/actions/runs/4465029569/jobs/7841709326#step:2:34)2:5) {

code: 32, killed: false, signal: null, cmd: 'C:\Windows\system32\cmd.exe /s /c "rd /s /q "%inputPath%""', stdout: '', stderr: 'The process cannot access the file because it is being used by another process.\r\n' }

cory-miller commented 1 year ago

If v3.3.0 fails, then it is not related to the change above. What's the minimum workflow I can use to reproduce this? The following is not enough.

name: Test

on:
  workflow_dispatch:

jobs:
  test_job:
    runs-on: windows-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
jun2zhou commented 1 year ago

this is my workflow working, if change to v3 the issue can be reproduced.

image

I installed two windows2022 runner, only the recent installed one has this issue. but I think the actions node js is running in the isolated env.

cr1pto commented 1 year ago

I ran into this issue today as well. Rolling back to checkout@v2 solved it for me too.

Aostas commented 1 year ago

I found that the https://github.com/actions/checkout/commit/dcd71f646680f2efd8db4afa5ad64fdcba30e748 commit caused this issue。 so v3.0.0 works fine,but v3.0.1 and above not

mithunpandey commented 1 year ago

facing this similar error when using the version actions/checkout@v3.5.0 OS: windows 10 Pro Action-runner-version: actions-runner-win-x64-2.304.0

C:\actions-runner\_work\_actions\actions\checkout\v3.5.0\dist\index.js:6844 throw new Error(File was unable to be removed ${err}`); ^

Error: File was unable to be removed Error: EBUSY: resource busy or locked, rmdir 'C:\actions-runner_work_temp\8ea00981-3dd3-40c7-b56b-eaf8ad9c2b3d' at Object. (C:\actions-runner_work_actions\actions\checkout\v3.5.0\dist\index.js:6844:19) at Generator.throw () at rejected (C:\actions-runner_work_actions\actions\checkout\v3.5.0\dist\index.js:6738:65)`

Are there some windows OS settings which can cause this issue ? Tried with v2 v3 and latest one also facing the same issue

vladimir-voinea commented 1 year ago

Running this in PowerShell as Administrator will fix it:

git config --system core.usebuiltinfsmonitor false

adityasomic commented 1 year ago

Hi @vladimir-voinea ,

I have the same issue , In my github repository there is one bash file which I would like to execute using the github actions , In this bash file there is one desktop application which I want to execute locally but I am getting error.

throw new Error(File was unable to be removed ${err}); ^

Error: File was unable to be removed Error: EBUSY: resource busy or locked, rmdir

Could you please tell me what I can do about it or Is it possible from the github action to start the desktop application and execute it using the bash file in the repository

ZVV1971 commented 10 months ago

The same issue started to appear on all versions of checkour 2, 3 & 4. Run actions/checkout@v4.1.1 Syncing repository: XXX Getting Git version info Temporarily overriding HOME='C:\actions-runner\_work\_temp\f054c8eb-74f7-4204-a725-048ba2feb4ef' before making global git config changes Adding repository directory to the temporary git global config as a safe directory "C:\Program Files\Git\cmd\git.exe" config --global --add safe.directory C:\actions-runner\_work\TetrisWPF\TetrisWPF "C:\Program Files\Git\cmd\git.exe" config --local --get remote.origin.url https://github.com/ZVV1971Org/TetrisWPF Removing previously created refs, to avoid conflicts "C:\Program Files\Git\cmd\git.exe" submodule status Cleaning the repository Disabling automatic garbage collection Setting up auth Fetching the repository Determining the checkout info Checking out the ref "C:\Program Files\Git\cmd\git.exe" log -1 --format='%H' '[23](https://github.com/ZVV1971Org/TetrisWPF/actions/runs/7240491383/job/19723708487#step:2:25)ea5ea94714c6308ad764bdaa63711c87f308bb' C:\actions-runner\_work\_actions\actions\checkout\v4.1.1\dist\index.js:6071 throw new Error(File was unable to be removed ${err}`); ^

Error: File was unable to be removed Error: EBUSY: resource busy or locked, rmdir 'C:\actions-runner_work_temp\f054c8eb-74f7-4204-a725-048ba2feb4ef' at Object. (C:\actions-runner_work_actions\actions\checkout\v4.1.1\dist\index.js:6071:19) at Generator.throw () at rejected (C:\actions-runner_work_actions\actions\checkout\v4.1.1\dist\index.js:5965:65)

Node.js v20.8.1`

ZVV1971 commented 10 months ago

image Two similar folders are created both with the same .gitconfig file inside. One is never removed before cleansing.

ZVV1971 commented 10 months ago

I've just found out that when I removed the folder from the gitconfig.safe section it begun to work fine again.

navachaitanyak commented 10 months ago

I have tried v3 and v4 , I'm facing the same issues, but when I tried v2, its working fine without any errors

n0passwords commented 10 months ago

This is also failing for v2-v4 for me, same reason - random GUID folder under _work.


Temporarily overriding HOME='C:\Users\gh-runner\actions-runner\_work\_temp\01089dac-59c1-49be-84b2-356bf9f4392e' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
"C:\Program Files\Git\cmd\git.exe" config --global --add safe.directory C:\Users\gh-runner\actions-runner\_work\0pass-app\0pass-app\0pass-app
"C:\Program Files\Git\cmd\git.exe" config --local --get remote.origin.url
https://github.com/0pass/0pass-app
Removing previously created refs, to avoid conflicts
"C:\Program Files\Git\cmd\git.exe" submodule status
Cleaning the repository
Disabling automatic garbage collection
Setting up auth
Fetching the repository
Determining the checkout info
Checking out the ref
"C:\Program Files\Git\cmd\git.exe" log -1 --format='%H'
'1ad[25](https://github.com/-------/actions/runs/7392295339/job/20110543102#step:2:27)9a3e6f015d8c44b506adf36e013ca2d2696'
C:\Users\gh-runner\actions-runner\_work\_actions\actions\checkout\v3\dist\index.js:6054
            throw new Error(`File was unable to be removed ${err}`);
                  ^

Error: File was unable to be removed Error: EBUSY: resource busy or locked, rmdir 'C:\Users\gh-runner\actions-runner\_work\_temp\01089dac-59c1-49be-84b2-[35](https://github.com-------/actions/runs/7392295339/job/20110543102#step:2:39)6bf9f[43](https://github.com/-------p/actions/runs/7392295339/job/20110543102#step:2:49)92e'
    at Object.<anonymous> (C:\Users\gh-runner\actions-runner\_work\_actions\actions\checkout\v3\dist\index.js:6054:19)
    at Generator.throw (<anonymous>)
    at rejected (C:\Users\gh-runner\actions-runner\_work\_actions\actions\checkout\v3\dist\index.js:5948:[65](https://github.com/-----------/actions/runs/7392295339/job/20110543102#step:2:73))```

For us, we actually have no files under _work/temp.
yi-ge commented 10 months ago

I encountered the same problem in version v3.

yi-ge commented 10 months ago

process monitor Through the analysis of relevant processes, I finally solved the problem, which was caused by git.exe occupying the folder. Refer to this comment for the fix.

ZalaPanda commented 3 months ago

For those who may have run out of ideas: set-safe-directory: false