Git error since latest update
michelkok opened this issue · comments
Since the last update (v2.295.0) I cannot run the following (simple) action anymore. I reran some old successful actions with the new version and those now also fail, so it's introduced in the latest release.
I tried to see what changed (root user etc.), but the default behavior seems to be similar mostly.
Here is my workflow:
jobs:
code_style:
name: Inspect code based on precommit configuration
runs-on: self-hosted
steps:
- name: Install Python ${{ inputs.python_version }}
uses: actions/setup-python@v3
with:
python-version: ${{ inputs.python_version }}
- name: Checkout repository
uses: actions/checkout@v3
- name: Install pre-commit
run: |
pip install pre-commit
pre-commit install # ERROR SINCE LAST UPDATE
- name: Run static code inspections
run: pre-commit run --all-files
This is the error message:
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
An error has occurred: FatalError: git failed. Is it installed, and are you in a Git repository directory?
Check the log at /root/.cache/pre-commit/pre-commit.log
Finally the relevant configuration from my compose file:
runner:
image: myoung34/github-runner:latest
container_name: github_runner
environment:
REPO_URL: https://github.com/repo
RUNNER_NAME: github_runner
RUNNER_WORKDIR: /tmp/runner/repo
env_file:
- stack.env
security_opt:
- label:disable
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
- '/tmp/runner:/tmp/runner'
The error gives two hints. I first confirmed, but Git is installed. Then I suspected I had somehow ended up in the wrong working directory, but when I do an ls
just before the failing pre-commit
command, I am indeed in the repository root. So, those two things seem not to be part of the problem.
Could you help me solve it?
EDIT
I set back the version explicitly to v2.294.0 but now the actions are still failing. While they were successful before. But I am not sure the problem lies within the update anymore.
v2.294.0 has indeed not been changed, only latest and the newest tags
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
is a warning but seems to indicate that youre running as root, which is the default (always has been) so that means youre not affected by the newest changes that are totally optional (non-root)
the real issue is obviously at An error has occurred: FatalError: git failed. Is it installed, and are you in a Git repository directory?
. It is definitely installed, so I'd crawl through /root/.cache/pre-commit/pre-commit.log
for any issues
Thanks for replying quickly.
I found out literally one second ago that in order to solve the issue, I have to add the following line before running pre-commit
: git config --global --add safe.directory /tmp/runner/repo/repo/repo
.
Not sure what caused this different in behavior though. I'll update & close once I know.
I think this is due to a somewhat recent git vulnerability: https://github.blog/2022-04-12-git-security-vulnerability-announced/
Yes, however, checkout has fixed this recently. I do not know what caused the trouble as that step (by default) runs the command that fixes it after it has checked out the repository.
Anyway, it's not an issue with this repository it seems, so I'll close. Thanks for the help!