CircleCI persist_to_workspace "no such file or directory"
persist_to_workspace copies paths (relative to its root) into the shared workspace for downstream jobs. A path that does not exist at that point, or a root/path mismatch, fails the persist.
What this error means
The persist_to_workspace step fails with no such file or directory for a listed path, so downstream attach_workspace finds nothing.
Error persisting to workspace: lstat /tmp/workspace/dist: no such
file or directory. The path must exist relative to the workspace root.Common causes
Path not produced yet
The build output that should be persisted was not created before the step.
Root and path mismatch
paths are resolved relative to root; an inconsistent root makes the path invalid.
How to fix it
Build, then persist with a consistent root
Produce the output before persisting and keep root and paths consistent.
steps:
- run: npm run build # creates dist/
- persist_to_workspace:
root: .
paths:
- distHow to prevent it
- Persist only paths that already exist at that step.
- Keep persist root and attach path consistent across jobs.
- Order build before persist_to_workspace.