pola-rs/polars · error · RuntimeError
Cannot locate
Error message
Cannot locate {launch_file} What it means
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.
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
Example fix
# before: no .vscode/launch.json in repo root # after: create .vscode/launch.json containing the 'Rust LLDB' configuration with a "pid" field, per contributing guide
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
launch_file = Path('py-polars/debug/launch.py').parents[2] / '.vscode/launch.json'
assert launch_file.exists(), f'Missing {launch_file}; create it per the contributing guide' Try / catch
try:
run_debug_flow()
except RuntimeError as e:
if str(e).startswith('Cannot locate'):
print('Create .vscode/launch.json per https://docs.pola.rs/development/contributing/ide/#debugging') Prevention
- 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
When it happens
Trigger: 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.
Common situations: Fresh clones without the debug launch configuration set up; monorepo layouts where launch.py's parents[2] is not the repo root.
Understand the failure class
Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.
Related errors
- Cannot locate pid definition in launch.json for Rust LLDB…
- launch.py is not meant to be executed directly; please use…
- no dynamic library found at path
- a non-HTTPS workspace_url was given
- accessing ` ` from the top-level `polars` module was…
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/e01ef4991e11a661.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/debug/launch.py:39
and execute the originally-requested script.
"""
if len(sys.argv) == 1:
msg = (
"launch.py is not meant to be executed directly; please use the `Python: "
"Debug Rust` debugging configuration to run a python script that uses the "
"polars library."
)
raise RuntimeError(msg)
# Get the current process ID.
pID = os.getpid()
# Print to the debug console to allow VSCode to pick up on the signal and start the
# Rust LLDB configuration automatically.
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:View on GitHub (pinned to fe841f959e)