langflow-ai/langflow · error · SystemExit

ripgrep (rg) is required for --rewrite-consumers but was not

Error message

ripgrep (rg) is required for --rewrite-consumers but was not found on PATH.

What it means

port_bundle.py's --rewrite-consumers feature shells out to ripgrep (rg) to find every repo file that imports the provider being ported, then rewrites those imports to the new bundle path. The script requires the rg binary; if `subprocess.check_output` raises FileNotFoundError (rg not on PATH), it aborts with SystemExit and this message rather than silently skipping the rewrite.

Source

Thrown at scripts/migrate/port_bundle.py:589

        # version fixtures).  The migration table rewrites these at flow
        # load time -- the bare-name + full-path + short-path entries
        # in the four-entry block we just appended cover every legacy
        # form Langflow has serialized.  Mechanically rewriting the
        # JSONs would defeat the migration test suite's purpose
        # (verifying frozen historical snapshots still load).
        "--glob",
        "!**/*.json",
        "-e",
        needles[0],
        "-e",
        needles[1],
        str(REPO_ROOT),
    ]
    try:
        out = subprocess.check_output(rg_cmd, text=True)  # noqa: S603
    except FileNotFoundError as exc:
        msg = "ripgrep (rg) is required for --rewrite-consumers but was not found on PATH."
        raise SystemExit(msg) from exc
    except subprocess.CalledProcessError as exc:
        # rg returns 1 when no matches are found; that's a legitimate
        # outcome (no external consumers exist).
        if exc.returncode == 1:
            return ()
        raise

    # The substitution order matters: do the most specific rewrite first
    # so the catch-all doesn't shadow it.  These ordered pairs are what
    # the datastax port applied by hand.
    base_subs = (
        # ``from lfx.base.<bundle> import X`` -> ``from lfx_<bundle>.base import X``
        (f"from lfx.base.{bundle} import", f"from lfx_{bundle}.base import"),
        # ``lfx.base.<bundle>.<module>`` patch-path form
        (f"lfx.base.{bundle}.", f"lfx_{bundle}.base."),
        # ``lfx.components.<bundle>.<module>`` patch-path / import-path form
        (f"lfx.components.{bundle}.", f"lfx_{bundle}.components.{bundle}."),
        # ``from lfx.components.<bundle> import X`` (re-export form) ->

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Install ripgrep: `apt install ripgrep` / `brew install ripgrep` / `cargo install ripgrep`, verify with `rg --version` in the same shell.
  2. If you cannot install rg, drop --rewrite-consumers and find/rewrite consumer imports manually (`grep -rn 'lfx.components.<bundle>' src/`).
  3. For CI, add ripgrep to the image or install it in a pipeline step before the port job.

Example fix

# before
docker run ci-image python scripts/migrate/port_bundle.py --bundle agentics --rewrite-consumers --apply
# error: ripgrep (rg) is required for --rewrite-consumers ...

# after
docker run ci-image sh -c "apt-get update && apt-get install -y ripgrep && python scripts/migrate/port_bundle.py --bundle agentics --rewrite-consumers --apply"
Defensive patterns

Strategy: validation

Validate before calling

import shutil

if not shutil.which("rg"):
    raise SystemExit(
        "--rewrite-consumers needs ripgrep. Install it (apt/brew install ripgrep) "
        "or drop the flag and rewrite imports manually."
    )

Type guard

import shutil

def ripgrep_available() -> bool:
    return shutil.which("rg") is not None

Prevention

When it happens

Trigger: Running `python scripts/migrate/port_bundle.py --bundle <name> --rewrite-consumers ...` on a machine without ripgrep installed or where rg is not on PATH for the Python process (sanitized CI environment, minimal Docker image, non-interactive shell without the user's PATH).

Common situations: Fresh CI containers that assume rg; local runs after switching package managers; remote/devcontainer environments where ripgrep was never installed; Windows without rg in PATH.

Related errors


AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14). Data as JSON: /api/errors/58b0268dc85d15d3. Report an issue: GitHub.