langflow-ai/langflow · error · SystemExit
orjson is required for --update-index (same dep scripts/buil
Error message
orjson is required for --update-index (same dep scripts/build_component_index.py uses). Run this script under ``uv run``.
What it means
port_bundle.py needs orjson (the same dependency scripts/build_component_index.py uses) when removing a bundle's category from the component index with --update-index. The script aborts with SystemExit when orjson cannot be imported, because index surgery is skipped rather than done with a different parser. The fix is to run under 'uv run' so the project environment with orjson is used.
Source
Thrown at scripts/migrate/port_bundle.py:1502
dst.write_text(_render_pilot_test(plan), encoding="utf-8")
return actions
def _update_component_index(plan: PortPlan, *, apply: bool) -> list[str]:
if not COMPONENT_INDEX_PATH.is_file():
return []
actions = [f"surgically remove {plan.bundle!r} category from {COMPONENT_INDEX_PATH.relative_to(REPO_ROOT)}"]
if not apply:
return actions
try:
import orjson
except ImportError as exc:
msg = (
"orjson is required for --update-index (same dep "
"scripts/build_component_index.py uses). Run this script "
"under ``uv run``."
)
raise SystemExit(msg) from exc
import hashlib
with COMPONENT_INDEX_PATH.open("rb") as f:
idx = json.loads(f.read())
entry = next((e for e in idx["entries"] if e[0] == plan.bundle), None)
if entry is None:
actions.append(f" (no {plan.bundle!r} entry in index; nothing to do)")
return actions
n_components = len(entry[1])
idx["entries"] = [e for e in idx["entries"] if e[0] != plan.bundle]
idx["metadata"]["num_modules"] -= 1
idx["metadata"]["num_components"] -= n_components
idx.pop("sha256", None)
payload = orjson.dumps(idx, option=orjson.OPT_SORT_KEYS)
idx["sha256"] = hashlib.sha256(payload).hexdigest()
out = orjson.dumps(idx, option=orjson.OPT_SORT_KEYS | orjson.OPT_INDENT_2)
COMPONENT_INDEX_PATH.write_bytes(out + b"\n")View on GitHub (pinned to 976ec789d2)
Solutions
- Run the script as 'uv run python scripts/migrate/port_bundle.py ... --update-index' so it executes in the workspace environment that has orjson.
- Alternatively install orjson into the active environment: 'uv pip install orjson' (or add it to the dev group).
- If index updates are not needed, drop --update-index and update the component index separately with scripts/build_component_index.py under uv.
Example fix
# before python scripts/migrate/port_bundle.py --apply --update-index # after uv run python scripts/migrate/port_bundle.py --apply --update-index
Defensive patterns
Strategy: validation
Validate before calling
import subprocess, sys
try:
import orjson # noqa: F401
except ImportError:
sys.exit("orjson missing — rerun as: uv run python scripts/migrate/port_bundle.py ...")
print("orjson ok; safe to pass --update-index") Prevention
- Always run repo scripts via 'uv run' so the workspace env (with orjson) is used.
- Keep orjson in the dev dependency group of the scripts' environment.
- Automate index updates with scripts/build_component_index.py under uv instead of ad-hoc interpreters.
When it happens
Trigger: Executing python scripts/migrate/port_bundle.py --apply --update-index with a bare system python or a venv that lacks orjson.
Common situations: Developer runs the script with 'python' instead of 'uv run'; CI image missing dev dependencies; a fresh virtualenv synced without the dev group.
Related errors
- provider directory not found: {src}
- destination already exists (already consolidated?): {dst}
- {provider}: source has subdirectory/ies {subdirs} that move_
- ripgrep (rg) is required for --rewrite-consumers but was not
- --bundle {bundle!r} is not a valid bundle name (lowercase sn
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/ba538c12dc1f2b4c.
Report an issue: GitHub.