You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No support for per-subpackage launch.json + in monorepo: debugger breaks imports that terminal run resolves #2047
Repo layout: monorepo with src/ layout; each sub-package at packages/<name>/src/<name>/
Shell: PowerShell
Problem
In a monorepo with a src/ layout, running python -m packages.api.main from the workspace root works in a terminal (with PYTHONPATH=packages/api/src). But when launching the same target via VS Code's debugger ("module": "packages.api.main" in launch.json), debugpy prepends its own path manipulation that:
Overrides PYTHONPATH in the subprocess environment.
Sets cwd to the workspace root unless explicitly overridden.
Does NOT pick up per-folder python.defaultInterpreterPath or env activation from a subfolder .vscode/settings.json.
Result: imports that resolve in a terminal fail in the debugger with ModuleNotFoundError, because debugpy's path injection shadows the manually set PYTHONPATH.
Activity
rchiodo commentedon Jul 1, 2026
I believe the expected way to handle this is to create a launch.json in the subfolder.
Then you'd just debug the packages/api/src/main file directly from the launch.json at packages/api/.vscode/launch.json
rchiodo commentedon Jul 1, 2026
That works for me if you add the subfolder as a top level folder in the workspace.
Here's what it looks like with the two launch.json files:
Otherwise you could instead set your
env.PYTHONPATHto whatever debugpy has set by printing it at the start of test file.