pola-rs/polars · error · RuntimeError

Cannot locate pid definition in launch.json for Rust LLDB…

Error message

Cannot locate pid definition in launch.json for Rust LLDB configuration. Please follow the instructions in the debugging section of the contributing guide (https://docs.pola.rs/development/contributing/ide/#debugging) for creating the launch configuration.

What it means

launch_debugging applies a regex to launch.json to find the 'Rust LLDB' configuration's pid field and replaces it with the current process id. If the regex does not match, the launch.json exists but lacks the expected Rust LLDB pid definition, so it raises this RuntimeError with a pointer to the contributing guide.

Solutions

  1. Follow the debugging setup at https://docs.pola.rs/development/contributing/ide/#debugging and recreate .vscode/launch.json exactly as documented
  2. Ensure the configuration is named 'Rust LLDB' and contains a "pid": <integer> field immediately after the name
  3. Restore the canonical launch.json from the contributing guide and re-run the 'Python: Debug Rust' configuration

Example fix

// before (.vscode/launch.json)
{"type": "lldb", "request": "attach", "name": "Rust debug"}
// after
{"type": "lldb", "request": "attach", "name": "Rust LLDB", "pid": 0}
Defensive patterns

Strategy: validation

Validate before calling

import re, pathlib
launch_info = pathlib.Path('.vscode/launch.json').read_text()
assert re.search(r'("Rust LLDB",\s*"pid":\s*)\d+(")', launch_info), "launch.json lacks the 'Rust LLDB' pid definition; see the contributing guide"

Try / catch

try:
    run_debug_flow()
except RuntimeError as e:
    if 'Cannot locate pid definition' in str(e):
        print('Recreate .vscode/launch.json per https://docs.pola.rs/development/contributing/ide/#debugging')

Prevention

When it happens

Trigger: launch.json exists but has no 'Rust LLDB' entry with a "pid": <number> field, or its formatting differs from the expected pattern ('Rust LLDB', followed by "pid": digits).

Common situations: Hand-edited launch.json (renamed configuration, removed pid, changed formatting/order); older launch.json templates predating the pid-based flow.

Understand the failure class

Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/d9e87de210530578. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/debug/launch.py:54

    launch_file = Path(__file__).parents[2] / ".vscode/launch.json"
    if not launch_file.exists():
        msg = f"Cannot locate {launch_file}"
        raise RuntimeError(msg)
    with launch_file.open("r") as f:
        launch_info = f.read()

    # Overwrite the pid found in launch.json with the pid for the current process.
    # Match the initial "Rust LLDB" definition with the pid defined immediately after.
    pattern = re.compile('("Rust LLDB",\\s*"pid":\\s*")\\d+(")')
    found = pattern.search(launch_info)
    if not found:
        msg = (
            "Cannot locate pid definition in launch.json for Rust LLDB configuration. "
            "Please follow the instructions in the debugging section of the "
            "contributing guide (https://docs.pola.rs/development/contributing/ide/#debugging) "
            "for creating the launch configuration."
        )
        raise RuntimeError(msg)

    launch_info_with_new_pid = pattern.sub(rf"\g<1>{pID}\g<2>", launch_info)
    with launch_file.open("w") as f:
        f.write(launch_info_with_new_pid)

    # Print pID to the debug console. This auto-triggers the Rust LLDB configurations.
    print(f"pID = {pID}")

    # Give the LLDB time to connect. Depending on how long it takes for your LLDB
    # debugging session to initialize, you may have to adjust this setting.
    time.sleep(LLDB_DEBUG_WAIT_TIME_SECONDS)

    # Update sys.argv so that when exec() is called, the first argument is the script
    # name itself, and the remaining are the input arguments.
    sys.argv.pop(0)
    with Path(sys.argv[0]).open() as fh:
        script_contents = fh.read()

View on GitHub (pinned to fe841f959e)