CircleCI attach_workspace "No workspace found" - Fix
A job ran attach_workspace but no workspace was available to attach. Either no upstream job persisted one, or this job does not depend on the job that did, so the data is not in scope.
What this error means
The downstream job fails at attach_workspace saying no workspace is available, or attaches an empty directory. Files persisted upstream never appear because the dependency chain is broken.
attach_workspace
- Attaching workspace...
- Error: No workspace found. Did an upstream job persist_to_workspace,
and does this job 'require' it?Common causes
No requires dependency on the persisting job
A workspace only flows to jobs downstream of the one that persisted it. Without requires: [build] in the workflow, the attaching job is not downstream and sees no workspace.
Upstream never persisted
If the upstream job did not run persist_to_workspace (or failed before it), there is nothing for this job to attach.
Wrong attach location
Attaching at a path that does not match how the files are referenced makes them look absent even when the workspace attached.
How to fix it
Add the requires dependency in the workflow
workflows:
ci:
jobs:
- build
- deploy:
requires:
- build # makes the build's workspace availableEnsure upstream persists what downstream attaches
- Confirm the upstream job runs
persist_to_workspaceafter producing files. - Use a matching
attach_workspace.atin the downstream job. - List the attached directory while debugging to confirm contents.
How to prevent it
- Wire
requires:so every attaching job is downstream of the persisting job. - Keep persist/attach roots consistent across the workflow.
- Fail fast by listing attached files in the downstream job.