How to Debug a Working Directory Issue in GitHub Actions
Most path failures come from a step running in a different directory than you assume; pwd and ls show the truth.
Print pwd, ls -la, and $GITHUB_WORKSPACE at the start of the failing step. Each step starts in the workspace root unless it sets working-directory, so a relative path may not resolve where you think.
Steps
- Add
pwdandls -labefore the failing command. - Confirm the file you expect is actually present.
- Set
working-directoryif the command needs a subfolder.
Workflow
.github/workflows/ci.yml
steps:
- uses: actions/checkout@v4
- name: Show where I am
run: |
echo "pwd = $(pwd)"
echo "workspace = $GITHUB_WORKSPACE"
ls -la
- name: Build in a subfolder
working-directory: services/api
run: |
pwd && ls -la
npm ci && npm run buildGotchas
working-directoryapplies only torun:steps, not touses:action steps.- A missing
actions/checkoutmeans the repo files are simply not there yet. - Each step resets to the workspace root; a
cdin one step does not carry to the next.
Related guides
How to SSH Into a Failed Runner With tmate in GitHub ActionsOpen an interactive SSH session into a live GitHub Actions runner using mxschmitt/action-tmate, so you can po…
How to Debug a Failing Step With bash Tracing in GitHub ActionsSee every command a GitHub Actions shell step runs, with variables expanded, by enabling bash xtrace via set…