Graphify-Labs/graphify · error · RuntimeError

tree-sitter {getattr(_ts, '__version__', 'unknown')} is too

Error message

tree-sitter {getattr(_ts, '__version__', 'unknown')} is too old. graphify requires tree-sitter >= 0.23.0 (Language API v2). Run: pip install --upgrade tree-sitter

What it means

Raised by _check_tree_sitter_version when tree-sitter IS installed but too old: its LANGUAGE_VERSION constant is below 14, meaning it predates the Language API v2 that graphify's parser bindings require. This deliberately separates 'wrong version installed' from 'not installed' so the fix is an upgrade, not a fresh install.

Source

Thrown at graphify/extract.py:3903

    return {"nodes": nodes, "edges": edges, "input_tokens": 0, "output_tokens": 0}


# ── Main extract and collect_files ────────────────────────────────────────────


def _check_tree_sitter_version() -> None:
    """Raise a clear error if tree-sitter is too old for the new Language API."""
    try:
        from tree_sitter import LANGUAGE_VERSION
    except ImportError:
        raise ImportError(
            "tree-sitter is not installed. Run: pip install 'tree-sitter>=0.23.0'"
        )
    # Language API v2 starts at LANGUAGE_VERSION 14
    if LANGUAGE_VERSION < 14:
        import tree_sitter as _ts
        raise RuntimeError(
            f"tree-sitter {getattr(_ts, '__version__', 'unknown')} is too old. "
            f"graphify requires tree-sitter >= 0.23.0 (Language API v2). "
            f"Run: pip install --upgrade tree-sitter"
        )


# ── .NET project files (.sln, .slnx, .csproj, .razor) ───────────────────────


def extract_slnx(path: Path) -> dict:
    """Extract projects and inter-project dependencies from a .slnx file.

    .slnx is the XML-based replacement for the legacy .sln format. Projects
    are listed as ``<Project Path="..."/>`` elements (optionally nested inside
    ``<Folder>`` elements) and build-order dependencies as ``<BuildDependency
    Project="..."/>`` children. Unlike .sln there are no GUIDs -- projects are
    identified by their path.
    """

View on GitHub (pinned to 7fe58b0b0f)

Solutions

  1. pip install --upgrade tree-sitter (to >= 0.23.0)
  2. If another dependency pins it, resolve the conflict: `pip install 'tree-sitter>=0.23.0'` and check `pip check` for the conflicting requirement
  3. If a system package owns it, install into a venv instead: `python -m venv .venv && .venv/bin/pip install --upgrade tree-sitter graphify`

Example fix

# before
pip show tree-sitter   # Version: 0.21.3
graphify build .        # RuntimeError: tree-sitter 0.21.3 is too old

# after
pip install --upgrade 'tree-sitter>=0.23.0'
graphify build .
Defensive patterns

Strategy: validation

Validate before calling

from tree_sitter import LANGUAGE_VERSION

if LANGUAGE_VERSION < 14:
    import tree_sitter
    raise SystemExit(
        f"tree-sitter {getattr(tree_sitter, '__version__', '?')} too old; "
        "upgrade: pip install --upgrade 'tree-sitter>=0.23.0'"
    )

Try / catch

try:
    graphify_extract(files)
except RuntimeError as e:
    if "tree-sitter" in str(e) and "too old" in str(e):
        subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "tree-sitter>=0.23.0"])
        graphify_extract(files)  # one retry after upgrade
    else:
        raise

Prevention

When it happens

Trigger: Running source extraction with tree-sitter < 0.23.0 installed (e.g. 0.20.x pinned by another tool) so `from tree_sitter import LANGUAGE_VERSION` succeeds but LANGUAGE_VERSION < 14, triggering the RuntimeError naming the detected __version__.

Common situations: A shared venv where another package (editor plugin, older extractor) pins tree-sitter to a pre-0.23 release; distro-provided python3-tree-sitter packages that lag; upgrading graphify without upgrading its native deps.

Related errors


AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14). Data as JSON: /api/errors/4e9666efa9f13c58. Report an issue: GitHub.