Skip to main content

Troubleshooting: attach_workspace Step Fails to Extract Workspace

Problem

The attach_workspace step fails when trying to extract workspace data in your CircleCI build. This typically occurs when using Alpine-based Docker images or images with BusyBox versions of tar and gzip utilities.

You may see one of these error messages in your build output:

Using busybox tar, if you run into issues, please try installing GNUtar.
Error uploading workspace archive: RequestError: send request failed

Solution

The attach_workspace step requires tar and gzip to extract workspace data. BusyBox versions of these utilities can cause compatibility issues. Install GNU (GNUtar) versions to resolve the problem.

Add this step to your job before using attach_workspace:

- run:
    name: Install GNU tar and gzip
    command: apk add --no-cache tar gzip

This installs the full GNU versions of tar and gzip, replacing the BusyBox versions that come with Alpine images.

Complete Example

version: 2.1jobs:
  downstream-job:
    docker:
      - image: alpine:latest
    steps:
      - run:
          name: Install GNU tar and gzip
          command: apk add --no-cache tar gzip
      - attach_workspace:
          at: /tmp/workspace
      - run:
          name: Use workspace files
          command: ls -la /tmp/workspace

Outcome

After installing GNU tar and gzip, your attach_workspace step should complete successfully. You'll see your workspace files extracted to the specified directory without errors.

If the issue persists after installing GNU tar and gzip, verify that:

  • Your upstream job successfully persisted data using persist_to_workspace

  • The workspace paths in your upstream job are correctly specified

  • The at parameter in attach_workspace points to a valid directory, and reinstalling them on Alpine images with apk add --no-cache tar gzip can help resolve problems.

Additional Resources

Did this answer your question?