Error: EPERM: operation not permitted

We have self hosted runners on windows 2019 server, When the CI script for github action is executed, the below error is thrown at the time of checkout@v2 step except when it runs first time to download the repository code.

“2020-11-20T08:51:53.0232472Z ##[error]EPERM: operation not permitted, unlink ‘C:\actions-runner_work\TSG-PEG-Agile-PEG-Demo\TSG-PEG-Agile-PEG-Demo\Peg.Web’”

Furthermore, it has been identified, it only creates issue for the script having “npm install command” as it downloads the node modules. This scripts runs fine/OK first time but on every other subsequent runs it throws error. It may be because at the time of checkout again already existing “node module” folder does not delete and throws this error.

Any suggestions are appreciated.
Thanks

Run actions/checkout@v2
Syncing repository: Bain/TSG-PEG-Agile-PEG-Demo
Getting Git version info
“C:\Program Files\Git\cmd\git.exe” config --local --get remote.origin.url
https://github.com/Bain/TSG-PEG-Agile-PEG-Demo
Removing previously created refs, to avoid conflicts
Cleaning the repository
Warning: Unable to clean or reset the repository. The repository will be recreated instead.
Deleting the contents of ‘C:\actions-runner_work\TSG-PEG-Agile-PEG-Demo\TSG-PEG-Agile-PEG-Demo’
Error: EPERM: operation not permitted, unlink ‘C:\actions-runner_work\TSG-PEG-Agile-PEG-Demo\TSG-PEG-Agile-PEG-Demo\Peg.Web’

3 Likes