CircleCI checkout "No such file or directory" - Fix
A step cannot find a file that should be in the repo. Usually the checkout step was skipped, the working_directory is wrong, or the path assumes a layout that does not exist after a clean clone.
What this error means
A step fails with "No such file or directory" for a file that exists in your repo. It runs against an empty or unexpected directory because the code was never checked out where the step looks.
#!/bin/bash -eo pipefail
./scripts/build.sh
bash: ./scripts/build.sh: No such file or directory
Exited with code 1Common causes
No checkout step before the command
CircleCI does not clone automatically. Without a checkout step earlier in the job, the working directory has no repo files.
Wrong working_directory
A job-level working_directory that does not match where checkout placed the code (or where the file lives) makes relative paths resolve to nothing.
Path assumes a different layout
The file is in a subdirectory, or was produced by an earlier job and not persisted/attached, so it is absent in this job’s clean checkout.
How to fix it
Add checkout before any step that reads the repo
jobs:
build:
docker: [{ image: cimg/base:current }]
steps:
- checkout # required - nothing is cloned without it
- run: ./scripts/build.shAlign working_directory and relative paths
- Drop a custom
working_directoryunless you truly need it; the default is fine. - Reference files relative to the checked-out repo root.
- For cross-job files, persist them upstream and
attach_workspacehere.
How to prevent it
- Put
checkoutfirst in every job that touches repo files. - Avoid custom
working_directoryunless required, and keep paths relative to the repo root. - Use workspaces to move generated files between jobs.