reflex-dev/reflex · error · SystemExit

Failed to create temp directory for extracting zip: {ose}

Error message

Failed to create temp directory for extracting zip: {ose}

What it means

Raised by `create_config_init_app_from_remote_template` when creating the second scratch directory for extracting the template zip fails with an OSError. Same environmental causes as the download temp-dir failure, but at the extraction stage; the CLI exits with SystemExit(1).

Source

Thrown at reflex/utils/templates.py:156

        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}")
        raise SystemExit(1)

    template_dir = unzip_dir / subdirs[0]
    logger.debug(f"Template folder is located at {template_dir}")

    # Move the rxconfig file here first.
    path_ops.mv(str(template_dir / constants.Config.FILE), constants.Config.FILE)

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Free space or remount /tmp writable, then re-run reflex init.
  2. Set TMPDIR to a larger writable location before running init.
Defensive patterns

Strategy: fallback

Validate before calling

import shutil

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

Prevention

When it happens

Trigger: `reflex init` from a remote template where mkdtemp() fails a second time (unwritable/full/missing TMPDIR) after the zip was successfully downloaded.

Common situations: Disk that filled during the zip download so the extraction mkdtemp fails; read-only /tmp in hardened containers; TMPDIR removed between calls.

Related errors


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