How to Fix Process completed with exit code 1 (GitHub Actions)
Quick Answer: Exit code 1 indicates a non-zero exit status from a command, meaning it failed. Check the job logs for the specific command that failed and its output. The fastest fix is often to review the log output directly preceding the 'Process completed with exit code 1' message to identify the error.
What Causes This Error
- Command or script failure (e.g., syntax error, missing dependency, incorrect path)
- Missing or incorrect environment variables
- Insufficient permissions for a file or directory
- Resource limits exceeded (e.g., memory, disk space)
- External service unavailability or API rate limits
Step-by-Step Fixes
Fix 1: Review Job Logs for Specific Error Messages
Navigate to the failed workflow run in GitHub Actions.,Click on the failed job.,Expand the step that shows 'Process completed with exit code 1'.,Read the output immediately preceding this message for specific error details (e.g., 'command not found', 'permission denied', 'syntax error').
Fix 2: Verify Paths and File Existence
If a script or binary is failing, ensure its path is correct and the file exists.,Add a `ls -l /path/to/file` step before the failing command to confirm its presence and permissions.,Use `pwd` to confirm the current working directory if relative paths are used.
Fix 3: Check Environment Variables
Confirm all required environment variables are set correctly in your workflow file (`.github/workflows/*.yml`).,Add a debug step to print relevant environment variables: `run: echo "MY_VAR=${{ env.MY_VAR }}"` or `run: printenv`.,Ensure secrets are correctly referenced using `secrets.MY_SECRET` and not `env.MY_SECRET`.
Fix 4: Test Commands Locally
Replicate the GitHub Actions runner environment as closely as possible (e.g., use a similar Docker image).,Run the failing command locally with the same inputs and environment variables.,This often provides more immediate and detailed error feedback than the CI logs.
Fix 5: Increase Verbosity or Add Debugging Steps
Modify the failing command to include a `--verbose` or `-v` flag if available.,Add `set -euxo pipefail` at the beginning of shell scripts to exit immediately on error and print commands as they are executed.,Insert `echo` statements at various points in scripts to trace execution flow and variable values.
Advanced Fixes
Advanced Fix 1: Advanced Fix: Debugging Docker container failures in GitHub Actions
Add a 'docker logs' command before the failing step if your workflow uses Docker containers. For example, if a service container fails, add a step like: `name: Debug Docker Logs`, `run: docker logs <container_name_or_id>`.,Use `docker ps -a` to list all containers (running and exited) to identify the container name/ID.,Consider using `docker exec -it <container_name_or_id> /bin/bash` in a temporary debug step to manually inspect the container's environment and file system if the runner allows interactive commands (though this is less common in standard CI setups).
Advanced Fix 2: Advanced Fix: Isolating dependency installation issues
Add a step to explicitly print the version of critical tools or dependencies. For example, for Node.js: `run: node -v && npm -v`. For Python: `run: python --version && pip --version`.,Introduce a step to list installed packages: `run: pip list` (Python) or `run: npm list` (Node.js) to verify dependencies are correctly installed.,Temporarily comment out parts of your build or test script to narrow down which specific command or section is causing the failure.
FAQs
Q:
A:
Q:
A:
Q:
A: