CodeQL "checkout path ... does not appear to be a git repository" in CI
CodeQL reads git metadata from the checkout to associate results with commits and files. If the working directory has no .git (checkout did not run, or ran with a different path), init fails immediately.
What this error means
The init step fails with "The checkout path provided to the action does not appear to be a git repository." No analysis runs.
Error: The checkout path provided to the action does not appear to be a git repository.
Please check the path and try again. (checkout_path: /home/runner/work/app/app)Common causes
CodeQL init runs before checkout
The init step executes before actions/checkout, so there is no repository on disk yet.
A custom checkout path CodeQL was not told about
Checkout used a non-default path, but CodeQL still looks at the default workspace, which is not a git repo.
How to fix it
Check out before init
- Place actions/checkout before the CodeQL init step.
- Do not remove the
.gitdirectory before analysis. - Re-run so init finds a valid repository.
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v3
with:
languages: pythonTell CodeQL about a custom checkout path
If checkout uses a non-default path, pass the same path to the CodeQL action so it reads the right repository.
- uses: actions/checkout@v4
with:
path: src
- uses: github/codeql-action/init@v3
with:
languages: python
source-root: srcHow to prevent it
- Always run checkout before CodeQL init.
- Keep the .git directory intact through analysis.
- Pass matching paths when using a custom checkout location.