{"record":{"id":"58b0268dc85d15d3","repo":"langflow-ai/langflow","slug":"ripgrep-rg-is-required-for-rewrite-consumers-b","errorCode":null,"errorMessage":"ripgrep (rg) is required for --rewrite-consumers but was not found on PATH.","messagePattern":"ripgrep \\(rg\\) is required for --rewrite-consumers but was not found on PATH\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"scripts/migrate/port_bundle.py","lineNumber":589,"sourceCode":"        # version fixtures).  The migration table rewrites these at flow\n        # load time -- the bare-name + full-path + short-path entries\n        # in the four-entry block we just appended cover every legacy\n        # form Langflow has serialized.  Mechanically rewriting the\n        # JSONs would defeat the migration test suite's purpose\n        # (verifying frozen historical snapshots still load).\n        \"--glob\",\n        \"!**/*.json\",\n        \"-e\",\n        needles[0],\n        \"-e\",\n        needles[1],\n        str(REPO_ROOT),\n    ]\n    try:\n        out = subprocess.check_output(rg_cmd, text=True)  # noqa: S603\n    except FileNotFoundError as exc:\n        msg = \"ripgrep (rg) is required for --rewrite-consumers but was not found on PATH.\"\n        raise SystemExit(msg) from exc\n    except subprocess.CalledProcessError as exc:\n        # rg returns 1 when no matches are found; that's a legitimate\n        # outcome (no external consumers exist).\n        if exc.returncode == 1:\n            return ()\n        raise\n\n    # The substitution order matters: do the most specific rewrite first\n    # so the catch-all doesn't shadow it.  These ordered pairs are what\n    # the datastax port applied by hand.\n    base_subs = (\n        # ``from lfx.base.<bundle> import X`` -> ``from lfx_<bundle>.base import X``\n        (f\"from lfx.base.{bundle} import\", f\"from lfx_{bundle}.base import\"),\n        # ``lfx.base.<bundle>.<module>`` patch-path form\n        (f\"lfx.base.{bundle}.\", f\"lfx_{bundle}.base.\"),\n        # ``lfx.components.<bundle>.<module>`` patch-path / import-path form\n        (f\"lfx.components.{bundle}.\", f\"lfx_{bundle}.components.{bundle}.\"),\n        # ``from lfx.components.<bundle> import X`` (re-export form) ->","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/scripts/migrate/port_bundle.py#L571-L607","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Install ripgrep: `apt install ripgrep` / `brew install ripgrep` / `cargo install ripgrep`, verify with `rg --version` in the same shell.","If you cannot install rg, drop --rewrite-consumers and find/rewrite consumer imports manually (`grep -rn 'lfx.components.<bundle>' src/`).","For CI, add ripgrep to the image or install it in a pipeline step before the port job."],"exampleFix":"# before\ndocker run ci-image python scripts/migrate/port_bundle.py --bundle agentics --rewrite-consumers --apply\n# error: ripgrep (rg) is required for --rewrite-consumers ...\n\n# after\ndocker run ci-image sh -c \"apt-get update && apt-get install -y ripgrep && python scripts/migrate/port_bundle.py --bundle agentics --rewrite-consumers --apply\"","handlingStrategy":"validation","validationCode":"import shutil\n\nif not shutil.which(\"rg\"):\n    raise SystemExit(\n        \"--rewrite-consumers needs ripgrep. Install it (apt/brew install ripgrep) \"\n        \"or drop the flag and rewrite imports manually.\"\n    )","typeGuard":"import shutil\n\ndef ripgrep_available() -> bool:\n    return shutil.which(\"rg\") is not None","tryCatchPattern":null,"preventionTips":["Pre-flight `shutil.which('rg')` in any wrapper script that passes --rewrite-consumers.","Bake ripgrep into CI images that run port_bundle.py.","Remember rg exit code 1 (no matches) is fine — only FileNotFoundError aborts."],"tags":["tooling","ripgrep","cli","dependencies"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}