FoundationAgents/OpenManus · error · RuntimeError

Failed to copy file: {e}

Error message

Failed to copy file: {e}

What it means

Catch-all RuntimeError from DockerSandbox.copy_from (app/sandbox/core/sandbox.py:313): any failure in the copy-out pipeline other than docker NotFound — writing the streamed tar to the temp file, tarfile.open/extract, extracting to dst, or host-side I/O (disk full, permission denied on dst_path). The specific cause is preserved in {e}.

Source

Thrown at app/sandbox/core/sandbox.py:313

                    else:
                        # If destination is a file, we only extract the source file's content
                        if len(members) > 1:
                            raise RuntimeError(
                                f"Source path is a directory but destination is a file: {src_path}"
                            )

                        with open(dst_path, "wb") as dst:
                            src_file = tar.extractfile(members[0])
                            if src_file is None:
                                raise RuntimeError(
                                    f"Failed to extract file: {src_path}"
                                )
                            dst.write(src_file.read())

        except docker.errors.NotFound:
            raise FileNotFoundError(f"Source file not found: {src_path}")
        except Exception as e:
            raise RuntimeError(f"Failed to copy file: {e}")

    async def copy_to(self, src_path: str, dst_path: str) -> None:
        """Copies a file to the container.

        Args:
            src_path: Source file path (host).
            dst_path: Destination path (container).

        Raises:
            FileNotFoundError: If source file does not exist.
            RuntimeError: If copy operation fails.
        """
        try:
            if not os.path.exists(src_path):
                raise FileNotFoundError(f"Source file not found: {src_path}")

            # Create destination directory in container
            resolved_dst = self._safe_resolve_path(dst_path)

View on GitHub (pinned to 52a13f2a57)

Solutions

  1. Read {e} to separate host I/O errors (PermissionError, ENOSPC) from tar errors.
  2. Pre-create and pre-check the destination: os.makedirs(dirname, exist_ok=True) and verify writability.
  3. Free host disk space; check df at the destination.
  4. Retry once on transient stream corruption; if persistent, fall back to run_command('cat path') for single small text files.
Defensive patterns

Strategy: try-catch

Validate before calling

os.makedirs(os.path.dirname(os.path.abspath(dst)) or ".", exist_ok=True)
assert os.access(os.path.dirname(os.path.abspath(dst)), os.W_OK)

Try / catch

try:
    await sandbox.copy_from(src, dst)
except RuntimeError as e:
    cause = e.__cause__ or e
    if isinstance(cause, PermissionError):
        os.chmod(dst_dir, 0o755); await sandbox.copy_from(src, dst)
    else:
        raise

Prevention

When it happens

Trigger: Host destination not writable or parent missing when opening dst_path; disk full while writing chunks; corrupted tar stream; tarfile.ExtractError on malformed archives; tempfile.TemporaryDirectory cleanup races.

Common situations: Running the host process as a user without write access to the destination; copying large artifacts to a full disk; antivirus/locked files on the host interfering with extraction; paths with spaces mishandled by surrounding code.

Related errors


AI-assisted analysis of FoundationAgents/OpenManus@52a13f2a57 (2026-08-15). Data as JSON: /api/errors/b07cc39abb58d677. Report an issue: GitHub.