{"record":{"id":"f9d369b92af8ab36","repo":"reflex-dev/reflex","slug":"failed-to-create-temp-directory-for-extracting-zip","errorCode":null,"errorMessage":"Failed to create temp directory for extracting zip: {ose}","messagePattern":"Failed to create temp directory for extracting zip: (.+?)","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"reflex/utils/templates.py","lineNumber":156,"sourceCode":"        response = net.get(template_url, follow_redirects=True)\n        logger.debug(f\"Server responded download request: {response}\")\n        response.raise_for_status()\n    except httpx.HTTPError as he:\n        logger.error(f\"Failed to download the template: {he}\")\n        raise SystemExit(1) from None\n    try:\n        zip_file_path.write_bytes(response.content)\n        logger.debug(f\"Downloaded the zip to {zip_file_path}\")\n    except OSError as ose:\n        logger.error(f\"Unable to write the downloaded zip to disk {ose}\")\n        raise SystemExit(1) from None\n\n    # Create a temp directory for the zip extraction.\n    try:\n        unzip_dir = Path(tempfile.mkdtemp())\n    except OSError as ose:\n        logger.error(f\"Failed to create temp directory for extracting zip: {ose}\")\n        raise SystemExit(1) from None\n\n    try:\n        zipfile.ZipFile(zip_file_path).extractall(path=unzip_dir)\n        # The zip file downloaded from github looks like:\n        # repo-name-branch/**/*, so we need to remove the top level directory.\n    except Exception as uze:\n        logger.error(f\"Failed to unzip the template: {uze}\")\n        raise SystemExit(1) from None\n\n    if len(subdirs := list(unzip_dir.iterdir())) != 1:\n        logger.error(f\"Expected one directory in the zip, found {subdirs}\")\n        raise SystemExit(1)\n\n    template_dir = unzip_dir / subdirs[0]\n    logger.debug(f\"Template folder is located at {template_dir}\")\n\n    # Move the rxconfig file here first.\n    path_ops.mv(str(template_dir / constants.Config.FILE), constants.Config.FILE)","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/utils/templates.py#L138-L174","documentation":"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).","triggerScenarios":"`reflex init` from a remote template where mkdtemp() fails a second time (unwritable/full/missing TMPDIR) after the zip was successfully downloaded.","commonSituations":"Disk that filled during the zip download so the extraction mkdtemp fails; read-only /tmp in hardened containers; TMPDIR removed between calls.","solutions":["Free space or remount /tmp writable, then re-run reflex init.","Set TMPDIR to a larger writable location before running init."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import shutil\n\ndef disk_ok(path=\"/tmp\", need_mb=100) -> bool:\n    return shutil.disk_usage(path).free >= need_mb * 1024 * 1024","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-check temp space for both download and extraction stages (extraction can need more than the zip size).","Use a writable, adequately sized TMPDIR in restricted environments."],"tags":["reflex","templates","tempdir","permissions","disk-full"],"backgroundTag":"temp-directory-creation-failed","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}