{"record":{"id":"bfd311cc3ff560dc","repo":"nexu-io/open-design","slug":"output-directory-already-exists-output-dir-use","errorCode":null,"errorMessage":"Output directory already exists: {output_dir}. Use --force to overwrite.","messagePattern":"Output directory already exists: (.+?)\\. Use --force to overwrite\\.","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"warning","filePath":"skills/chat-motion-overlay/scripts/prepare_chat_overlay_bundle.py","lineNumber":72,"sourceCode":"        template_dir(),\n    }\n    if output_dir in dangerous_targets:\n        raise SystemExit(\n            f\"Refusing to use dangerous output directory: {output_dir}. \"\n            \"Choose a dedicated generated-bundle directory instead.\"\n        )\n    if output_dir.exists() and force and not bundle_marker_path(output_dir).exists():\n        raise SystemExit(\n            f\"Refusing to overwrite unmanaged output directory: {output_dir}. \"\n            f\"Only directories containing {BUNDLE_MARKER} can be replaced with --force.\"\n        )\n\n\ndef copy_template(output_dir: Path, force: bool) -> None:\n    validate_output_dir(output_dir, force)\n    if output_dir.exists():\n        if not force:\n            raise SystemExit(f\"Output directory already exists: {output_dir}. Use --force to overwrite.\")\n        shutil.rmtree(output_dir)\n    shutil.copytree(template_dir(), output_dir)\n    bundle_marker_path(output_dir).write_text(\"generated by chat-motion-overlay\\n\", encoding=\"utf-8\")\n\n\ndef write_chat_spec_ts(spec: dict, output_dir: Path) -> None:\n    target = output_dir / \"src\" / \"chatSpec.ts\"\n    content = \"export const chatSpec = \" + json.dumps(spec, ensure_ascii=False, indent=2) + \" as const;\\n\"\n    target.write_text(content, encoding=\"utf-8\")\n\n\ndef remove_local_upload_paths(spec: dict) -> None:\n    for participant in spec[\"participants\"]:\n        participant.pop(\"uploadPath\", None)\n\n\ndef copy_avatar_assets(spec: dict, output_dir: Path) -> dict:\n    upload_sources: list[tuple[dict, Path]] = []","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/chat-motion-overlay/scripts/prepare_chat_overlay_bundle.py#L54-L90","documentation":"Thrown by copy_template() when the output directory already exists and --force was not passed. Without --force the tool will neither overwrite nor merge, so it stops and asks for explicit consent.","triggerScenarios":"Run prepare_chat_overlay_bundle.py --output-dir <existing dir> without the --force flag.","commonSituations":"Re-running the script after a previous successful bundle into the same folder; CI caching a bundle dir between runs; forgetting --force in a fresh-look wrapper script.","solutions":["Pass --force to overwrite a previously generated bundle (only works if the dir carries the BUNDLE_MARKER).","Point --output-dir at a new unique directory for this run.","Delete the existing directory first if you want a clean generation without --force."],"exampleFix":"# before\npython prepare_chat_overlay_bundle.py --output-dir ./bundle  # already exists\n# after\npython prepare_chat_overlay_bundle.py --output-dir ./bundle --force","handlingStrategy":"validation","validationCode":"from pathlib import Path\ndef assert_output_ok(output_dir: Path, force: bool) -> None:\n    if output_dir.exists() and not force:\n        raise SystemExit(f\"{output_dir} exists; pass --force or choose a new dir\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Include --force in CI scripts that regenerate bundles into the same path.","Use unique per-run output dirs to avoid collisions."],"tags":["filesystem-safety","chat-motion-overlay","bundle-prep"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}