{"record":{"id":"d0b1411a9fe07589","repo":"reflex-dev/reflex","slug":"for-template-name-template-template-code-dir","errorCode":null,"errorMessage":"For `{template_name}` template, `template_code_dir_name` and `template_dir` should both be provided.","messagePattern":"For `(.+?)` template, `template_code_dir_name` and `template_dir` should both be provided\\.","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"reflex/utils/templates.py","lineNumber":74,"sourceCode":"        SystemExit: If template_name, template_code_dir_name, template_dir combination is not supported.\n    \"\"\"\n    logger.info(\"Initializing the app directory.\")\n\n    # By default, use the blank template from local assets.\n    if template_name == constants.Templates.DEFAULT:\n        if template_code_dir_name is not None or template_dir is not None:\n            logger.error(\n                f\"Only {template_name=} should be provided, got {template_code_dir_name=}, {template_dir=}.\"\n            )\n            raise SystemExit(1)\n        template_code_dir_name = constants.Templates.Dirs.CODE\n        template_dir = Path(constants.Templates.Dirs.BASE, \"apps\", template_name)\n    else:\n        if template_code_dir_name is None or template_dir is None:\n            logger.error(\n                f\"For `{template_name}` template, `template_code_dir_name` and `template_dir` should both be provided.\"\n            )\n            raise SystemExit(1)\n\n    logger.debug(f\"Using {template_name=} {template_dir=} {template_code_dir_name=}.\")\n\n    # Remove __pycache__ dirs in template directory and current directory.\n    for pycache_dir in [\n        *template_dir.glob(\"**/__pycache__\"),\n        *Path.cwd().glob(\"**/__pycache__\"),\n    ]:\n        shutil.rmtree(pycache_dir, ignore_errors=True)\n\n    for file in template_dir.iterdir():\n        # Copy the file to current directory but keep the name the same.\n        path_ops.cp(str(file), file.name)\n\n    # Rename the template app to the app name.\n    path_ops.mv(template_code_dir_name, app_name)\n    path_ops.mv(\n        Path(app_name) / (template_name + constants.Ext.PY),","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/utils/templates.py#L56-L92","documentation":"Raised by `reflex.utils.templates.initialize_app_directory` when a non-default template is requested but its location on disk is not fully specified. Custom templates are not bundled, so Reflex requires BOTH template_code_dir_name and template_dir to locate the code; providing only one is ambiguous and the app cannot be scaffolded.","triggerScenarios":"Calling initialize_app_directory(template_name=\"my_template\") with template_code_dir_name=None or template_dir=None (or omitting one of them). Reached via create_config_init_app_from_remote_template after downloading a template zip whose layout didn't yield the expected values.","commonSituations":"Passing a custom template name without its directory; a remote template download path failing to populate template_dir before initialization is called.","solutions":["Provide both template_code_dir_name (e.g. 'code' or the subdir inside the template containing the app) and template_dir (absolute or relative path to the extracted template).","If you wanted the bundled starter, use template_name=constants.Templates.DEFAULT with no extra args."],"exampleFix":"# before\ninitialize_app_directory(template_name=\"crypto_dashboard\")\n\n# after\ninitialize_app_directory(\n    template_name=\"crypto_dashboard\",\n    template_dir=Path(\"/tmp/unpacked/crypto_dashboard\"),\n    template_code_dir_name=\"code\",\n)","handlingStrategy":"validation","validationCode":"from reflex import constants\n\ndef validate_template_args(name, code_dir_name, template_dir):\n    if name != constants.Templates.DEFAULT:\n        assert code_dir_name is not None and template_dir is not None, (\n            \"custom templates need both template_code_dir_name and template_dir\"\n        )","typeGuard":null,"tryCatchPattern":null,"preventionTips":["For custom templates always pass the pair (template_dir, template_code_dir_name) together.","Use constants.Templates.DEFAULT when you want the bundled starter with no extra args."],"tags":["reflex","templates","init","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}