Skip to content
Latchkey

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.

job log
#!/bin/bash -eo pipefail
./scripts/build.sh
bash: ./scripts/build.sh: No such file or directory
Exited with code 1

Common 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

.circleci/config.yml
jobs:
  build:
    docker: [{ image: cimg/base:current }]
    steps:
      - checkout          # required - nothing is cloned without it
      - run: ./scripts/build.sh

Align working_directory and relative paths

  1. Drop a custom working_directory unless you truly need it; the default is fine.
  2. Reference files relative to the checked-out repo root.
  3. For cross-job files, persist them upstream and attach_workspace here.

How to prevent it

  • Put checkout first in every job that touches repo files.
  • Avoid custom working_directory unless required, and keep paths relative to the repo root.
  • Use workspaces to move generated files between jobs.

Related guides

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