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.
circleci
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.
.circleci/config.yml
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.
Related guides
CircleCI save_cache Path Does Not ExistFix CircleCI save_cache warnings when a path does not exist - the directory was never created, has a differen…
CircleCI Test Splitting "no timing data found"Fix CircleCI test splitting falling back to name-based splitting because no timing data was found - the first…
CircleCI Machine Executor Image Not FoundFix CircleCI machine executor image not found - an invalid, deprecated, or removed machine image tag, or a tr…