Skip to content
Latchkey

GitHub Actions defaults.run shell / working-directory Not Applied

A defaults.run block sets shell or working-directory, but some steps ignore it - because defaults only affect run steps, a step overrides it locally, or the block is at the wrong scope.

What this error means

A step runs in the wrong directory or uses the wrong shell despite a defaults.run block. uses steps are unaffected, and any step with its own shell or working-directory wins.

.github/workflows/ci.yml
defaults:
  run:
    working-directory: ./app
jobs:
  build:
    steps:
      - uses: actions/setup-node@v4   # defaults.run does NOT apply to uses steps
      - run: npm ci                    # runs in ./app

Common causes

defaults.run applies only to run steps

shell and working-directory under defaults.run affect run steps only. A uses step is unaffected; pass it inputs explicitly instead.

Step-level override or wrong scope

A step that sets its own shell or working-directory overrides the default. A defaults block at the wrong level (under a step instead of workflow or job) does not apply broadly.

How to fix it

Place defaults at workflow or job level

.github/workflows/ci.yml
defaults:
  run:
    shell: bash
    working-directory: ./app
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - run: pwd   # ./app, bash

Handle uses steps explicitly

  1. Pass a working directory to a uses action via its own inputs, not defaults.run.
  2. Set per-step shell or working-directory only when overriding the default intentionally.
  3. Keep defaults under the workflow or a job, never under a single step.

How to prevent it

  • Remember defaults.run governs run steps only.
  • Configure uses actions through their documented inputs.
  • Override shell or working-directory per step only when you mean to.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →