langflow-ai/langflow · warning · SystemExit
Bundle directory already exists: {bundle_dir}. Refusing to
Error message
Bundle directory already exists: {bundle_dir}. Refusing to overwrite. What it means
Third guard in port_bundle.py's eligibility check: the destination BUNDLES_DIR/<bundle> must not already exist. The script refuses to overwrite an existing bundle directory because a re-run would interleave with the previous port's files, migrations, and workspace registration. Exit with 'Bundle directory already exists: <path>. Refusing to overwrite.'
Source
Thrown at scripts/migrate/port_bundle.py:685
) -> PortPlan:
"""Refuse early if the candidate is not eligible for the mechanical port."""
if not re.fullmatch(r"[a-z][a-z0-9_]{1,63}", bundle):
msg = (
f"--bundle {bundle!r} is not a valid bundle name (lowercase "
"snake_case, 2-64 chars, starts with a letter). This script "
"ports an in-tree provider folder named exactly the same."
)
raise SystemExit(msg)
in_tree = LFX_COMPONENTS / bundle
if not in_tree.is_dir():
msg = f"In-tree provider directory not found: {in_tree}"
raise SystemExit(msg)
bundle_dir = BUNDLES_DIR / bundle
if bundle_dir.exists():
msg = f"Bundle directory already exists: {bundle_dir}. Refusing to overwrite."
raise SystemExit(msg)
deactivated_dup = LFX_COMPONENTS / "deactivated" / bundle
if deactivated_dup.is_dir():
msg = (
f"A deactivated duplicate exists at {deactivated_dup}. Resolve "
"the duplicate manually before porting -- see "
"src/bundles/PORTING.md § 0."
)
raise SystemExit(msg)
component_files: list[ComponentFile] = []
nested_subdirs: list[Path] = []
for src in sorted(in_tree.iterdir()):
if src.is_dir():
if src.name == "__pycache__":
continue
# Nested subpackage (e.g. ``agentics/helpers``); validate
# its files for ``from langflow`` imports too, then planView on GitHub (pinned to 976ec789d2)
Solutions
- If the earlier port completed, don't re-port — continue from its state or amend it directly.
- If it's debris from an aborted run, remove the destination directory (and any workspace/pyproject registrations it made) and re-run from clean: `git clean -fd src/bundles/` after reviewing `git status`.
- Never point --bundle at an existing bundle expecting an in-place update; the script is create-only by design.
Example fix
# before python scripts/migrate/port_bundle.py --bundle agentics --apply # second attempt # error: Bundle directory already exists: src/bundles/agentics. Refusing to overwrite. # after git status src/bundles/agentics # decide: keep prior port, or: rm -rf src/bundles/agentics && git checkout -- pyproject.toml && python scripts/migrate/port_bundle.py --bundle agentics --apply
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
BUNDLES_DIR = Path("src/bundles")
def bundle_absent(bundle: str) -> bool:
return not (BUNDLES_DIR / bundle).exists() Prevention
- The script is create-only; never re-run against an existing bundle directory expecting an update.
- Clean aborted runs fully (bundle dir + pyproject/workspace registrations) before retrying, ideally via git clean/checkout.
When it happens
Trigger: Re-running port_bundle.py for a bundle that was already ported (destination committed or left over from an aborted run); a name collision with a hand-created bundle scaffold.
Common situations: Retry after an interrupted --apply; running the port twice because the first run's output was missed; leftover directories from a reverted PR.
Related errors
- destination already exists (already consolidated?): {dst}
- provider directory not found: {src}
- In-tree provider directory not found: {in_tree}
- No ``*.py`` files under {in_tree}; nothing to port.
- lfx-{bundle} already referenced in {ROOT_PYPROJECT.relative_
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/66ed3ae95fa7cc06.
Report an issue: GitHub.