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.
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 ./appCommon 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
defaults:
run:
shell: bash
working-directory: ./app
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: pwd # ./app, bashHandle uses steps explicitly
- Pass a working directory to a uses action via its own inputs, not defaults.run.
- Set per-step shell or working-directory only when overriding the default intentionally.
- 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.