{"record":{"id":"8662bc3dbdd1a046","repo":"larksuite/cli","slug":"lark-cli-not-found","errorCode":null,"errorMessage":"lark-cli not found","messagePattern":"lark-cli not found","errorType":"exception","errorClass":"LarkCliError","httpStatus":null,"severity":"error","filePath":"skills/lark-sheets/scripts/lark_sheet_read_cli.py","lineNumber":76,"sourceCode":"\n    cmd = [\"lark-cli\", \"sheets\", shortcut]\n    _append_flag(cmd, \"url\", url)\n    _append_flag(cmd, \"spreadsheet_token\", spreadsheet_token)\n    _append_flag(cmd, \"sheet_id\", sheet_id)\n    _append_flag(cmd, \"sheet_name\", sheet_name)\n    for key, value in (flags or {}).items():\n        _append_flag(cmd, key, value)\n\n    try:\n        completed = subprocess.run(\n            cmd,\n            capture_output=True,\n            text=True,\n            timeout=timeout,\n            check=False,\n        )\n    except FileNotFoundError as exc:\n        raise LarkCliError(\"lark-cli not found\", cmd=cmd) from exc\n    except subprocess.TimeoutExpired as exc:\n        raise LarkCliError(f\"lark-cli timed out after {timeout}s\", cmd=cmd) from exc\n\n    if completed.returncode != 0:\n        detail = (completed.stderr or completed.stdout or \"\").strip()\n        raise LarkCliError(detail or f\"lark-cli exited with {completed.returncode}\", cmd=cmd)\n\n    try:\n        envelope = json.loads(completed.stdout)\n    except json.JSONDecodeError as exc:\n        snippet = completed.stdout[:500].replace(\"\\n\", \"\\\\n\")\n        raise LarkCliError(f\"lark-cli stdout was not JSON: {snippet}\", cmd=cmd) from exc\n\n    if isinstance(envelope, dict) and envelope.get(\"ok\") is False:\n        raise LarkCliError(json.dumps(envelope, ensure_ascii=False), cmd=cmd)\n    if not isinstance(envelope, dict):\n        raise LarkCliError(\"lark-cli returned a non-object JSON payload\", cmd=cmd)\n    return envelope","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/skills/lark-sheets/scripts/lark_sheet_read_cli.py#L58-L94","documentation":"run_sheets() shells out to the `lark-cli` executable via subprocess. When the OS raises FileNotFoundError because `lark-cli` is not on PATH, the library wraps it as LarkCliError(\"lark-cli not found\", cmd=cmd) so callers get a typed error naming the attempted command instead of a raw subprocess exception.","triggerScenarios":"Any run_sheets()-based call (read, check_sheet, inspect_workbook, detect_subtables, profile_table) when the lark-cli binary is not installed or not in the PATH of the Python process.","commonSituations":"Fresh machine or CI container where lark-cli was never installed; running the script from cron/IDE/venv whose PATH differs from the shell; lark-cli installed under a different name or via a build that did not put the binary on PATH.","solutions":["Install lark-cli (make build or its release install) and ensure the binary is on PATH.","Verify with `which lark-cli` / `lark-cli --version` in the same environment that runs the Python script.","If PATH differs (cron, systemd, IDE), extend os.environ['PATH'] in the script or invoke lark-cli by absolute path.","Activate the correct virtualenv/shell before running the script."],"exampleFix":"// before\nrun_sheets(\"read\", url=url)  # LarkCliError: lark-cli not found\n\n// after\nimport os, shutil\nif shutil.which(\"lark-cli\") is None:\n    os.environ[\"PATH\"] += os.pathsep + \"/usr/local/bin\"\nrun_sheets(\"read\", url=url)","handlingStrategy":"validation","validationCode":"import shutil\nif shutil.which(\"lark-cli\") is None:\n    raise SystemExit(\"lark-cli is not installed or not on PATH; install it or fix PATH\")","typeGuard":"def lark_cli_available() -> bool:\n    import shutil\n    return shutil.which(\"lark-cli\") is not None","tryCatchPattern":"try:\n    data = run_sheets(shortcut, url=url)\nexcept LarkCliError as e:\n    if \"lark-cli not found\" in str(e):\n        raise SystemExit(\"Install lark-cli and ensure it is on PATH\") from e\n    raise","preventionTips":["Install lark-cli during environment/CI setup and verify with `lark-cli --version`.","Use absolute paths or explicit PATH setup in cron/systemd/IDE contexts.","Add a shutil.which preflight to scripts that shell out to lark-cli."],"tags":["python","environment","missing-binary","path"],"backgroundTag":"command-not-found","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}