Search code examples
github-actionsgithub-actions-self-hosted-runners

"Permission denied" when deleting files inside of .git folders


I'm getting an error in my self-hosted github runners:

rm: cannot remove '/home/user/github-actions/1/_work/project/project/.git/index': Permission denied

It's not just this one file, but all the files that it tries to delete.

If I run something like: sudo chmod -R 777 . in the home directory, it will temporarily fix it. But the issue will come back. What can I do to fix this permenantly?


Solution

  • When your runner fails with this error, double-check the output of:

    ls -alrth /home/user/github-actions/1/_work/project/project/.git/index
    ps -eaf|grep -i runner
    

    That way, you can see:

    • who has created that file
    • what user is executing the current runner process

    That allows you to confirm a user process issue (one executing the runner, the other the files).

    I wonder if Git is running as a separate user or something

    No, it should not.