{"record":{"id":"e01ef4991e11a661","repo":"pola-rs/polars","slug":"cannot-locate-launch-file","errorCode":null,"errorMessage":"Cannot locate {launch_file}","messagePattern":"Cannot locate (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"py-polars/debug/launch.py","lineNumber":39,"sourceCode":"    and execute the originally-requested script.\n    \"\"\"\n    if len(sys.argv) == 1:\n        msg = (\n            \"launch.py is not meant to be executed directly; please use the `Python: \"\n            \"Debug Rust` debugging configuration to run a python script that uses the \"\n            \"polars library.\"\n        )\n        raise RuntimeError(msg)\n\n    # Get the current process ID.\n    pID = os.getpid()\n\n    # Print to the debug console to allow VSCode to pick up on the signal and start the\n    # Rust LLDB configuration automatically.\n    launch_file = Path(__file__).parents[2] / \".vscode/launch.json\"\n    if not launch_file.exists():\n        msg = f\"Cannot locate {launch_file}\"\n        raise RuntimeError(msg)\n    with launch_file.open(\"r\") as f:\n        launch_info = f.read()\n\n    # Overwrite the pid found in launch.json with the pid for the current process.\n    # Match the initial \"Rust LLDB\" definition with the pid defined immediately after.\n    pattern = re.compile('(\"Rust LLDB\",\\\\s*\"pid\":\\\\s*\")\\\\d+(\")')\n    found = pattern.search(launch_info)\n    if not found:\n        msg = (\n            \"Cannot locate pid definition in launch.json for Rust LLDB configuration. \"\n            \"Please follow the instructions in the debugging section of the \"\n            \"contributing guide (https://docs.pola.rs/development/contributing/ide/#debugging) \"\n            \"for creating the launch configuration.\"\n        )\n        raise RuntimeError(msg)\n\n    launch_info_with_new_pid = pattern.sub(rf\"\\g<1>{pID}\\g<2>\", launch_info)\n    with launch_file.open(\"w\") as f:","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/debug/launch.py#L21-L57","documentation":"After checking argv, launch_debugging computes the repo's .vscode/launch.json path (two directories above launch.py) and raises this RuntimeError if the file does not exist, since it needs to rewrite the pid there.","triggerScenarios":"Running the debug flow from a checkout or worktree where .vscode/launch.json is missing, deleted, or was never created; running launch.py from an installed/copied location rather than the repo root layout.","commonSituations":"Fresh clones without the debug launch configuration set up; monorepo layouts where launch.py's parents[2] is not the repo root.","solutions":["Create .vscode/launch.json with the 'Rust LLDB' and 'Python: Debug Rust' configurations per https://docs.pola.rs/development/contributing/ide/#debugging","Run the script from a proper polars source checkout where py-polars/debug/launch.py sits two levels under the repo root","Verify the file exists: ls <repo-root>/.vscode/launch.json"],"exampleFix":"# before: no .vscode/launch.json in repo root\n# after: create .vscode/launch.json containing the 'Rust LLDB' configuration with a \"pid\" field, per contributing guide","handlingStrategy":"validation","validationCode":"from pathlib import Path\nlaunch_file = Path('py-polars/debug/launch.py').parents[2] / '.vscode/launch.json'\nassert launch_file.exists(), f'Missing {launch_file}; create it per the contributing guide'","typeGuard":null,"tryCatchPattern":"try:\n    run_debug_flow()\nexcept RuntimeError as e:\n    if str(e).startswith('Cannot locate'):\n        print('Create .vscode/launch.json per https://docs.pola.rs/development/contributing/ide/#debugging')","preventionTips":["Commit or template .vscode/launch.json in the polars checkout you debug from","Run debug tooling only from a proper source checkout, not installed packages","Check file existence before running the debug flow"],"tags":["python","debugging","vscode","file-not-found"],"backgroundTag":"config-file-not-found","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}