CodeQL "fatal error while running codeql database create" in CI
The CodeQL CLI ran codeql database create and the process exited abnormally. This wraps a lower-level failure: the extractor crashed, the build under it failed, or the runner ran out of memory or disk.
What this error means
The init or analyze step fails with "Encountered a fatal error while running \"...codeql database create...\"". The exit code and a trace point to the underlying extractor or build failure.
Error: Encountered a fatal error while running "/opt/hostedtoolcache/CodeQL/.../codeql database create ...".
Exit code was 32 and last log line was: Spawned process exited abnormally (code 1) ...Common causes
The build under the extractor failed
For compiled languages the extractor drives your build; if that build errors, database create reports a fatal error.
The runner ran out of memory or disk mid-extraction
Large codebases can exhaust runner RAM or disk during extraction, killing the process abnormally.
How to fix it
Fix the underlying build first
- Read the "last log line" and exit code the error prints.
- Reproduce the build command it wrapped and fix the real compiler or dependency error.
- Re-run so database create completes over a working build.
Give the job more resources
Move the CodeQL job to a larger runner and free disk so extraction does not exhaust memory or space.
jobs:
analyze:
runs-on: ubuntu-latest-4-cores
steps:
- run: rm -rf "$AGENT_TOOLSDIRECTORY" || trueHow to prevent it
- Ensure the build succeeds standalone before wrapping it in CodeQL.
- Size the runner for the codebase to avoid OOM during extraction.
- Keep the CodeQL CLI and action up to date for extractor fixes.