Skip to content
Latchkey

CircleCI persist_to_workspace Errors - Fix Workspace Saves

persist_to_workspace did not store what you expected to hand to a later job. The paths are relative to root, and a mismatch means the workspace is empty or missing the files the downstream job needs.

What this error means

A later job that runs attach_workspace is missing build artifacts, or the persist step errors that a path does not exist under the root. The handoff between jobs loses data.

job log
persist_to_workspace
  - root: workspace
  - path "dist" not found under root "workspace"
Error: nothing to persist

Common causes

paths are not under root

Each entry in paths is resolved relative to root. Listing dist when the output is at ./dist but root: workspace points elsewhere persists nothing.

Persisting before the files exist

If persist_to_workspace runs before the build produces the artifacts, there is nothing to store.

Root mismatch between persist and attach

The downstream attach_workspace.at should match how you reference the files. A different at location makes the files appear "missing" even though they were persisted.

How to fix it

Set root and paths consistently

.circleci/config.yml
jobs:
  build:
    steps:
      - checkout
      - run: npm ci && npm run build   # produces ./dist
      - persist_to_workspace:
          root: .
          paths:
            - dist
            - node_modules

Attach at a matching location downstream

.circleci/config.yml
  deploy:
    steps:
      - attach_workspace:
          at: .
      - run: ls dist && ./deploy.sh

How to prevent it

  • Persist after the build, with paths relative to root.
  • Use a consistent root / at convention across jobs.
  • List ls of the attached dir in the downstream job while debugging.

Frequently asked questions

What causes "persist_to_workspace errors"?
Each entry in paths is resolved relative to root. Listing dist when the output is at ./dist but root: workspace points elsewhere persists nothing.
How do I fix persist_to_workspace errors?
Set root and paths consistently

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card