reflex-dev/reflex · error · SystemExit

Unable to write the downloaded zip to disk {ose}

Error message

Unable to write the downloaded zip to disk {ose}

What it means

Raised by `create_config_init_app_from_remote_template` when the downloaded zip bytes cannot be written to disk (OSError from zip_file_path.write_bytes). The download itself succeeded, but persisting it to the temp directory failed, so initialization aborts.

Source

Thrown at reflex/utils/templates.py:149

        logger.error(f"Failed to create temp directory for download: {ose}")
        raise SystemExit(1) from None

    # Use httpx GET with redirects to download the zip file.
    zip_file_path: Path = Path(temp_dir) / "template.zip"
    try:
        # Note: following redirects can be risky. We only allow this for reflex built templates at the moment.
        response = net.get(template_url, follow_redirects=True)
        logger.debug(f"Server responded download request: {response}")
        response.raise_for_status()
    except httpx.HTTPError as he:
        logger.error(f"Failed to download the template: {he}")
        raise SystemExit(1) from None
    try:
        zip_file_path.write_bytes(response.content)
        logger.debug(f"Downloaded the zip to {zip_file_path}")
    except OSError as ose:
        logger.error(f"Unable to write the downloaded zip to disk {ose}")
        raise SystemExit(1) from None

    # Create a temp directory for the zip extraction.
    try:
        unzip_dir = Path(tempfile.mkdtemp())
    except OSError as ose:
        logger.error(f"Failed to create temp directory for extracting zip: {ose}")
        raise SystemExit(1) from None

    try:
        zipfile.ZipFile(zip_file_path).extractall(path=unzip_dir)
        # The zip file downloaded from github looks like:
        # repo-name-branch/**/*, so we need to remove the top level directory.
    except Exception as uze:
        logger.error(f"Failed to unzip the template: {uze}")
        raise SystemExit(1) from None

    if len(subdirs := list(unzip_dir.iterdir())) != 1:
        logger.error(f"Expected one directory in the zip, found {subdirs}")

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Free disk space in TMPDIR (df -h) and retry init.
  2. Point TMPDIR at a volume with more space: TMPDIR=$HOME/tmp reflex init.
  3. Check for permission/quota issues on the temp volume.
Defensive patterns

Strategy: fallback

Validate before calling

import shutil

def disk_ok(path="/tmp", need_mb=50) -> bool:
    return shutil.disk_usage(path).free >= need_mb * 1024 * 1024

Prevention

When it happens

Trigger: Template URL downloads fine but the temp directory fills up mid-write, loses permissions, or the filesystem errors (ENOSPC, EACCES, disk quota) while writing template.zip in the mkdtemp directory.

Common situations: Disk filling exactly during download (large template, low space); tmpfs size limits in containers; antivirus/lockers blocking writes on some platforms.

Related errors


AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28). Data as JSON: /api/errors/d299e2a2e6a8f055. Report an issue: GitHub.