CircleCI workspace: attach path does not match persist in CI
A downstream job ran attach_workspace at a different at: path than the upstream persist_to_workspace root:, so the expected files are not where the job looks. Files are present, just under the wrong relative path.
What this error means
A later step fails with "no such file or directory" for an artifact that an earlier job persisted, even though the persist step succeeded.
cp: cannot stat 'dist/app.js': No such file or directory
Exited with code exit status 1Common causes
The attach path differs from the persist root
persist_to_workspace used root: . with paths: [dist], but attach_workspace used at: /tmp/ws, so files land under a different relative path than expected.
A path listed for persist was not produced
The persist step listed a path the job never created, so nothing was stored for the downstream job to attach.
How to fix it
Keep root and at paths consistent
- Choose one workspace root and reuse it in both jobs.
- Persist relative paths under that root.
- Attach at the same root and reference files relative to it.
# upstream
- persist_to_workspace:
root: .
paths: [dist]
# downstream
- attach_workspace:
at: .
- run: cp dist/app.js out/List the attached tree to confirm layout
Print the workspace after attaching so the actual file paths are visible.
- run: find . -maxdepth 2 -name 'app.js'How to prevent it
- Use one consistent workspace root across jobs.
- Persist only paths the job actually creates.
- Reference attached files relative to the attach
at:path.