Skip to content
Latchkey

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 pwd and ls -la before the failing command.
  • Confirm the file you expect is actually present.
  • Set working-directory if 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 build

Gotchas

  • working-directory applies only to run: steps, not to uses: action steps.
  • A missing actions/checkout means the repo files are simply not there yet.
  • Each step resets to the workspace root; a cd in one step does not carry to the next.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →